我做了这个简单的例子,但在数据库中插入数据使用过程,始终得到这个错误Procedure or Function 'InsertInfo' expects parameter '@s_name', which was not supplied.
美中不足的是,表中插入数据,但显示错误!
HTML文件: -
{C}
代码(CS): - publiv void insertData()
{
SqlConnection con = new SqlConnection(str_con);
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "InsertInfo";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
string a = Convert.ToString(txtName.Text);
int b = Convert.ToInt32(txtPhone.Text);
string c = txtDegree.Text;
cmd.Parameters.Add("@s_name", SqlDbType.VarChar).Value = a;
cmd.Parameters.Add("@s_phone", SqlDbType.Int).Value = b;
cmd.Parameters.Add("@s_degree", SqlDbType.VarChar).Value = c;
//cmd.Parameters.AddWithValue("@s_name", a);<------tried with these also
//cmd.Parameters.AddWithValue("@s_phone", b);
//cmd.Parameters.AddWithValue("@s_degree", c);
cmd.ExecuteNonQuery();<-------error points here
con.Close();
}
存储过程: -
{体C3}我向你乞求,请帮我找到错误。