如何使用C#代码将图像保存在Informix数据库中?使用C#代码将图像保存在Informix数据库中?
目前,我无法使用C#代码将图像保存在Informix数据库中。
所有的步骤都工作,只有当查询即将执行时,它会抛出错误“E42000:(-201)发生了语法错误。”
以下是代码。
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();
你试过了什么吗?我觉得不是。请阅读[常见问题]和[问] –
尝试了很多,但它引发了一些错误“E42000:(-201)发生了语法错误。” – user1881251
写下你的代码,错误信息和关于你的特定问题的更多信息。 –