Click here to Skip to main content
13,085,936 members (94,702 online)
Rate this:
Please Sign up or sign in to vote.
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.

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);
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);
lblMessage.Text = "Image details inserted successfully";
Posted 4-Jan-13 23:51pm
Updated 5-Jan-13 0:21am

1 solution

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 5 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100