Stored procedure or function expects parameter which was not supplied

后端 未结 9 1153
梦谈多话
梦谈多话 2021-01-17 08:47

I am trying to insert data into a SQL Server database by calling a stored procedure, but I am getting the error

*Procedure or function \'Insertion\'

9条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-17 09:36

    Your Insertion stored procedure is expecting @Emp_no (along with about 15 other parameters). You cannot call the stored procedure without passing the parameters.

    Take a look at this site for reference:

    http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparametercollection.addwithvalue.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-2

    Everywhere you're defining variables, use Parameters.AddWithValue instead:

    cmd.Parameters.AddWithValue("@Emp_no ", Convert.ToInt32(txtbx_Empno.Text));
    

提交回复
热议问题