0
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..........

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • The error is pretty clear: one of the values you provide (`@a` through `@e`) is longer than what it's column in SQL Server is defined at. Check your column definitions against the values you're trying to store - at least one will be too long – marc_s Sep 12 '14 at 05:14

1 Answers1

1

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! :)

Community
  • 1
  • 1
jomsk1e
  • 3,585
  • 7
  • 34
  • 59