hi
i have problem with saving jpeg image to sql server
below is my saving code
*************
string con_string = System.Configuration.ConfigurationManager.AppSettings["con_string"];
System.Data.SqlClient.SqlConnection conobj = new System.Data.SqlClient.SqlConnection(con_string);
string sql = "INSERT INTO Docs (nid,photo) VALUES (@nid,@photo)";
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(sql, conobj);
int length = photoupload.PostedFile.ContentLength;
//create a byte array to store the binary image data
byte[] imgbyte = new byte[length];
//store the currently selected file in memeory
HttpPostedFile img = photoupload.PostedFile;
//set the binary data
img.InputStream.Read(imgbyte, 0, length);
cmd.Parameters.AddWithValue("@nid",nid_lbl .Text );
cmd.Parameters.Add("@photo", SqlDbType.VarBinary ).Value = imgbyte;
cmd.Connection = conobj;
conobj.Open();
cmd.ExecuteNonQuery();
conobj.Close();
***************
and my docs table structure is like below
**********
nid char
photo varbinary(max)
************
a new row add to docs table when i press save button but after retrieve using handler it show nothing to image control
my retrieve handler is correct problem is with save procedure
please help
thanks
Can you answer this question?
Answer
0 Answers