User-836358016 posted
i want to insert image into access db using asp.net c# fileupload dialog box. but i am facing issue in command cmd.executenonquery. below is my code
Rgds,
Prasad
if (!FileUpload1.HasFile)
{
Label1.Visible = true;
Label1.Text = "Please Select Image File";
}
else
{
int length = FileUpload1.PostedFile.ContentLength;
byte[] pic = new byte[length];
FileUpload1.PostedFile.InputStream.Read(pic, 0, length);
string str = FileUpload1.FileName;
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/uploads/" + str));
string Image = "~/Uploads/" + str.ToString();
connection();
OleDbCommand cmd = new OleDbCommand("insert into ImageToTable values(@id,@Image,@name)", con);
cmd.Parameters.AddWithValue("@id", TextBox1.Text);
cmd.Parameters.AddWithValue("@Image", Image);
cmd.Parameters.AddWithValue("@name", TextBox2.Text);
cmd.ExecuteNonQuery(); <----------------------------------------error occurs here
Label1.Visible = true;
Label1.Text = "Image Uploaded Sucessfully";
con.Close();