storeimage.ExecuteNonQuery();
Incorrect syntax near image content
protected void btnadd_Click(object sender, EventArgs e) { if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "") { byte[] myimage = new byte[FileUpload1.PostedFile.ContentLength]; HttpPostedFile Image = FileUpload1.PostedFile; Image.InputStream.Read(myimage, 0, (int)FileUpload1.PostedFile.ContentLength); SqlConnection myConnection = new SqlConnection("Data Source=MAC-PC\\SQLEXPRESS;Initial Catalog=Populate_Pictures;Integrated Security=True"); SqlCommand storeimage = new SqlCommand("Insert_into_Populate_pictures" + "(image_content,image_type,image_size)" + "values(@image_content,@image_type,@image_size)", myConnection); storeimage.Parameters.Add("@image_content", SqlDbType.Image, myimage.Length).Value = myimage; storeimage.Parameters.Add("@imagtype", SqlDbType.VarChar, 100).Value = FileUpload1.PostedFile.ContentType; storeimage.Parameters.Add("@imagesize", SqlDbType.BigInt, 9999).Value = FileUpload1.PostedFile.ContentLength; myConnection.Open(); storeimage.ExecuteNonQuery(); myConnection.Close(); GridView1.DataSource = FetchAllImagesInfo(); GridView1.DataBind(); } } public DataTable FetchAllImagesInfo() { string sql="Select * from Candidate_Images"; SqlDataAdapter da = new SqlDataAdapter(sql, "Data Source=MAC-PC\\SQLEXPRESS;Initial Catalog=Populate_Pictures;Integrated Security=True"); DataTable dt= new DataTable (); da.Fill(dt); return dt; } }
+ " (image_content,image_type,image_size) " ^ ^
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)