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
[OperationContract]
string insertuser(Employeedetails employee);
}
[DataContract]
public class insertuser
{
[DataMember]
public string name { get; set; }
[DataMember]
public string sex { get; set; }
[DataMember]
public string Department { get; set; }
[DataMember]
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 = isu.name.ToString();
sex = isu.sex.ToString();
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);
Sqlcon.Open();
int result= cmd.ExecuteNonQuery();
if (result == 1)
{
message = "Details are isnerted Sucessfully";
}
else
{
message = "Details are not inserted Sucessfully";
}
Sqlcon.Close();
return message;
throw new NotImplementedException();
}
}
}
Then i have created a asp.net 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