MemoryStream ms1 = new MemoryStream();
MemoryStream ms2 = new MemoryStream();
customer_pic_1.Image.Save(ms1,System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] img_arr1 = new byte[ms1.Length];
ms1.Read(img_arr1,0,img_arr1.Length);
//ImageConverter converter = new ImageConverter();
//return (byte[])converter.ConvertTo(img_arr1, typeof(byte[]));
cmd.Parameters.AddWithValue("@a", name_txt.Text );
cmd.Parameters.AddWithValue("@b", designation_txt.Text);
cmd.Parameters.AddWithValue("@c", mobile_txt.Text);
cmd.Parameters.AddWithValue("@d", mail_txt.Text);
cmd.Parameters.AddWithValue("@e", image_path_txt.Text);
cmd.Parameters.AddWithValue("@f", img_arr1);
int result = cmd.ExecuteNonQuery();
if (result > 0)
{
MessageBox.Show("Ur Data Inserted Successfully....$");
}
else
{
MessageBox.Show("Sorry Ur data inserting Fail...!");
}
conx.Close();
While inserting the image I get an error:
string or binary data would be truncated. The statement has been terminated.
Please help for me .....
I tried in both i.e. in backend for image column image varbinary also I had used.....it is not working..........
The maximal length of the target column is shorter than the value you try to insert. Try editing the table's column for that.
And additionally please read this. Welcome to SO! :)