如何摆脱这个错误无法找到存储过程'cmd'。为什么? [英] How to get rid of this error Could not find stored procedure 'cmd'.? why?
本文介绍了如何摆脱这个错误无法找到存储过程'cmd'。为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
代码是
code in Dataaccess layer is
public DataSet FindRecord(int RollNumber)
{
using (SqlConnection con = new SqlConnection(cs))
{
//string cmd = "Select * from tblstudent where RollNumber=@RollNumber";
SqlCommand cmd = new SqlCommand("spfindtblstudent", con);
cmd.Parameters.AddWithValue("@RollNumber", RollNumber);
SqlDataAdapter da = new SqlDataAdapter("cmd", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
return ds;
}
}
推荐答案
带走双引号......
这个:
Take away the double quotes...
This:
SqlDataAdapter da = new SqlDataAdapter("cmd", con);
成为:
Becomes this:
SqlDataAdapter da = new SqlDataAdapter(cmd);
这篇关于如何摆脱这个错误无法找到存储过程'cmd'。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文