public int Insert(Student s)
{
con.Open();
cmd = new SqlCommand("Insert into Students (stdid, studname) values" + "(@stdid, @studname)", con);
SqlParameter[] prm = new SqlParameter[2];
prm[0] = new SqlParameter("@stdid",SqlDbType.Int);
prm[1] = new SqlParameter("@studname", SqlDbType.VarChar, 50);
prm[0].Value = s.studentid;
prm[1].Value = s.studentname;
cmd.CommandType = CommandType.Text;
return cmd.ExecuteNonQuery();
}
我得到这样的错误。
必须声明标量变量"@ stdid"。