本文介绍了参数化查询'(@colid int)从tbl_college中选择collogo,其中colid = @ colid'需要@colid参数,但未提供该参数.如何解决此错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



谁能知道解决这个错误的方法?



Can anyone know hoe to solve this error?

Parameterized Query '(@colid int)Select collogo from tbl_college where colid=@colid' expects parameter @colid, which was not supplied.how to solve this error?

public void ProcessRequest (HttpContext context)
    {
        SqlConnection cn = new SqlConnection(ConfigurationManager.AppSettings["constring"].ToString());
        cn.Open();

        string sql = "Select collogo from tbl_college where colid=@colid";
        SqlCommand cmd = new SqlCommand(sql, cn);
        cmd.Parameters.Add("@colid", SqlDbType.Int).Value = context.Request.QueryString["colid"];
        cmd.Prepare();
        SqlDataReader dr = cmd.ExecuteReader();
        dr.Read();
        //context.Response.ContentType = dr["imagename"].ToString();
        context.Response.BinaryWrite((byte[])dr["collogo"]);
        dr.Close();
        cn.Close(); 
        
    }

推荐答案


context.Request.QueryString["colid"]

为空


这篇关于参数化查询'(@colid int)从tbl_college中选择collogo,其中colid = @ colid'需要@colid参数,但未提供该参数.如何解决此错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 11:10