You must Sign In to post a response.
  • Category: WCF

    Insert the data to db using Wcf

    I am creating a wcf application and to consume in ASP.NET.

    IN ISERVICE .CS File i have wrote a below code

    string insertuser(Employeedetails employee);

    public class insertuser
    public string name { get; set; }
    public string sex { get; set; }
    public string Department { get; set; }
    public int Salary { get; set; }


    In SVC.cs file

    public string insertuser(Employeedetails employee)

    SqlConnection Sqlcon = new SqlConnection("Connectionstring");
    //Employeedetails EM = new WcfService.Employeedetails();
    string name=string.Empty;
    string sex=string.Empty;
    string Department = string.Empty;
    int salary=0;
    string message = string.Empty;
    insertuser isu = new WcfService.insertuser();
    name =;
    sex =;
    Department = isu.Department.ToString();
    salary = isu.Salary;

    SqlCommand cmd = new SqlCommand("insert into employee(name,sex,department,salary)values('" + name.ToString() + "','" + sex.ToString() + "', '" + salary + "')", Sqlcon);
    int result= cmd.ExecuteNonQuery();
    if (result == 1)
    message = "Details are isnerted Sucessfully";

    message = "Details are not inserted Sucessfully";

    return message;

    throw new NotImplementedException();


    Then i have created a application for consuming using Addreference method
    in the new file i created four textbox and button.

    in the button event

    i wrote the below code
    ServiceReference1.Service1Client objService = new ServiceReference1.Service1Client();
    objService.insertuser(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text)

    im facing the below Error: Method are not implemented
  • #769359

    Check below given link:">

  • #769360

    Why you have written the line throw new NotImplementedException(); remove it.
    Add try catch blocks in insertuser implementation so that you can know the exception if any.

    Sridhar Thota.
    Editor: DNS Forum.

  • Sign In to post your comments