本文介绍了参数化查询'(@cid int)从tbl_company1中选择clogo,其中cid = @ cid'需要参数@cid,该参数未提供.无法准备声明.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以帮忙吗?
如何解决此错误?
Can anyone help?
how to solve this error?
Parameterized Query '(@cid int)Select clogo from tbl_company1 where cid=@cid' expects parameter @cid, which was not supplied.
Statement(s) could not be prepared.
我的代码:
my code:
public void ProcessRequest (HttpContext context)
{
// SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString);
SqlConnection cn = new SqlConnection(ConfigurationManager.AppSettings["constring"].ToString());
cn.Open();
string sql = "Select clogo from tbl_company1 where cid=@cid";
SqlCommand cmd = new SqlCommand(sql, cn);
cmd.Parameters.Add("@cid", SqlDbType.Int).Value = context.Request.QueryString["cid"];
cmd.Prepare();
SqlDataReader dr = cmd.ExecuteReader();
// dr.Read();
if (dr.Read())
{
//context.Response.ContentType = dr["imagename"].ToString();
context.Response.BinaryWrite((byte[])dr["clogo"]);
}
dr.Close();
cn.Close();
}
推荐答案
context.Request.QueryString["cid"]
为空.
检查它.
is null.
Check it.
这篇关于参数化查询'(@cid int)从tbl_company1中选择clogo,其中cid = @ cid'需要参数@cid,该参数未提供.无法准备声明.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!