Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Saving image in informix database by c# code ?

Unable to save image in informix database by using c# code.


All the steps work only when the query is about to get executed it throws error "E42000: (-201) A syntax error has occurred."

Below is the code.

mycon.Open();
int len = Upload.PostedFile.ContentLength;
byte[] pic = new byte[len];
HttpPostedFile img = Upload.PostedFile;
Response.Write("Size of file = " + pic);
img.InputStream.Read(pic, 0, len);
//Upload.PostedFile.InputStream.Read(pic,0,len);
string str = "insert into imageinfo (name,address,photo) values('" + txtname.Text + "','" + txtaddress.Text + "'," + pic + ")";//,photo,@photo
mycmd = new OleDbCommand(str, mycon);
// mycmd.Parameters.AddWithValue("@id", int.Parse(txtid.Text));
mycmd.Parameters.AddWithValue("@name", txtname.Text);
mycmd.Parameters.AddWithValue("@address", txtaddress.Text);
mycmd.Parameters.AddWithValue("@photo", pic);
mycmd.ExecuteNonQuery();
mycon.Close();
lblMessage.Text = "Image details inserted successfully";
Response.Redirect("~/RetriveImage.aspx");
mycon.Close();
Posted
Updated 5-Jan-13 0:21am
v2

1 solution

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