i want to add record in the database using C#. but when i click to "ADD" button message box appears with message that
Employee Record could not be added!!!!"
What I have tried:
<pre>
string qry = "execute insertemplab @Employee_id,@Emplyee_name,@Emplyee_phone,@Employee_address,@Employee_type,@clothmanufacture";
SqlConnection connection = getconnection();
SqlCommand command = new SqlCommand(qry, connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@Employee_ID", lab.Employee_ID);
command.Parameters.AddWithValue("Emplyee_Name", lab.EmployeeName);
command.Parameters.AddWithValue("@Emplyee_phone", lab.PhoneNumber);
command.Parameters.AddWithValue("@Employee_Address", lab.EmployeeAddress);
command.Parameters.AddWithValue("@Employee_Type", lab.EmployeType);
command.Parameters.AddWithValue("@clothmanufacture", lab.ClothManufactured);
try{
command.ExecuteNonQuery();
MessageBox.Show("Employee Record Added Successfully");
}
catch (SqlException ex)
{
MessageBox.Show("Employee Record could not be added!!!!");
}
}
//when click to add button
LaboureClass lab = new LaboureClass(txtlaboureID.Text, txtname.Text, txtphone.Text, txtaddress.Text, txttype.Text, int.Parse(txtmanufacture.Text));
DBconnect.addEmployerecord(lab);
//this is my procedure in SQL server
create proc insertemplab @Employee_id varchar(50), @Emplyee_name varchar(50),
@Emplyee_phone varchar(50), @Employee_address varchar(50), @Employee_type varchar(50),@clothmanufacture varchar(50)
as
begin
insert into Employee_tbl(Employee_id,Emplyee_name,Emplyee_phone,Employee_address,Employee_type) values(@Employee_id, @Emplyee_name, @Emplyee_phone, @Employee_address, @Employee_type)
insert into Labour_tbl(L_Employee_id,clothmanufacture) values(@Employee_id,@clothmanufacture)
end