I've seen some posts here about how to INSERT just an image into an SQL database, but I just can't find any information about how to INSERT an image plus some other data. For example, if you want to send INSERT INTO SQL statement to server with values from some textboxes plus an image from an imagebox. Here is my code:
string sql;
System.IO.MemoryStream picStream = new System.IO.MemoryStream();
emp_picture.Image.Save(picStream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] bytePic = picStream.ToArray();
sql = "INSERT INTO employees (employee_number, first_name, last_name, address, city, " +
"zip_code, contact_info, truck_number, trailer_number, picture) " +
"VALUES ('" + Driver_Number.Text + "', '" + First_Name.Text + "', '" + Last_Name.Text +
"', '" + Address.Text + "', '" + City.Text + "', '" + Zip_Code.Text + "', '" + Contact_info.Text + "', '" +
Truck_Number.Text + "', '" + Trailer_Number.Text +"', '"+bytePic+"')";
When I try to retrieve the image it says, "Parameter is not valid." I know used a plain string without any parameters that is why it throws that exception. I just don't know if I can use parameters to send a message to server or not. I'd appreciate any ideas about how to solve this problem. Thanks.