-5
我創建表單需要從存儲過程的訪問,當我跑我得到這個錯誤的應用程序:過程或函數「spAddEmployee」需要參數「@name」,但未提供
Procedure or function 'spAddEmployee' expects parameter '@name', which was not supplied
C#代碼:
string connectionstring = ConfigurationManager.ConnectionStrings["AddEmployee"].ConnectionString;
using (SqlConnection con = new SqlConnection(connectionstring))
{
SqlCommand cmd = new SqlCommand("dbo.spAddEmployee", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
SqlParameter paramname = new SqlParameter();
paramname.ParameterName = "@Name";
paramname.Value = employee.Name;
cmd.Parameters.Add(paramname);
SqlParameter paramgender = new SqlParameter();
paramname.ParameterName = "@gender";
paramname.Value = employee.Gender;
cmd.Parameters.Add(paramgender);
SqlParameter paramcity = new SqlParameter();
paramname.ParameterName = "@city";
paramname.Value = employee.City;
cmd.Parameters.Add(paramcity);
SqlParameter paramdateofbirth = new SqlParameter();
paramdateofbirth.ParameterName = "@dateofbirth";
paramname.Value = employee.Dateofbirth;
cmd.Parameters.Add(paramdateofbirth);
cmd.ExecuteNonQuery();
con.Close();
}
my procedure code is given in snapshot
請幫我
是感謝您的幫助,現在我可以訪問我的存儲過程 –