How to fix this error System.Data.SqlClient.SqlException: 'Procedure or function 'SP_Delete' expects parameter '@empid', which was not supplied.'

Nenavath Santhosh 0 Reputation points
2023-11-22T06:54:33.24+00:00

create procedure SP_Delete

@empid int

as

begin

delete from empp where EMPNO=@empid

end

 private void btnDelete_Click(object sender, EventArgs e)
 {
     SqlConnection con = new SqlConnection("server=;user id=sa;password=lenovo;database=dbns116");
     SqlCommand cmd = new SqlCommand("SP_Delete", con);
     SqlParameter P1 = new SqlParameter("@empid", SqlDbType.Int);
     P1.Value = textBox1.Text;
     cmd.Parameters.Add(P1);
     con.Open();
     SqlDataReader Dr=cmd.ExecuteReader();
     con.Close();
     MessageBox.Show(" Records Deleted");
 }
Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.