Click here to Skip to main content
15,921,203 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

Can anyone help?
how to solve this error?

SQL
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:

C#
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();

  }
Posted
Updated 9-Feb-12 19:44pm
v2

1 solution

value of
C#
context.Request.QueryString["cid"]
is null.
Check it.
 
Share this answer
 
Comments
sathiyak 10-Feb-12 1:57am    
how to check...i am a beginner...so pls tell

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900