title: How to insert and retrieve image from SQL Server?
body: <p>I have written code to insert an Image in SQL server but it throws an exception:</p>
  
  <blockquote>
    <p>String or binary data would be truncated. The statement has been terminated.</p>
  </blockquote>
  
  <p>Here is my Code for insert image:</p>
  
  <pre><code>FileStream imageStream = new FileStream(CvVariables.IMAGE_PATH, FileMode.Open, FileAccess.Read);
  int fileLangth = (int)imageStream.Length;
  byte[] imageInBytes = new byte[fileLangth];
  imageStream.Read(imageInBytes, 0, (int)fileLangth);
  Cv_Customer_Information addNewCustomer = new Cv_Customer_Information
  {
        UserID = this.NewCustomerTextUserName.Text,
        UserImage =new System.Data.Linq.Binary(imageInBytes),
        Date = this.NewCustomerDate.SelectedDate.ToString(),
        Name = this.NewCustomerTextBoxName.Text,
        Phone = this.NewCustomerTextBoxPhone.Text,
        Email = this.NewCustomerTextBoxEmail.Text,
        NationalID = this.NewCustomerTextBoxNationalID.Text,
        Address = this.NewCustomerTextBoxAddress.Text
  };
  singupDataContext.Cv_Customer_Informations.InsertOnSubmit(addNewCustomer);
  singupDataContext.SubmitChanges();
  </code></pre>
  
  <p>I also don`t understand how to retrieve images from SQL Server?</p>
  
  <p>update: I use image Data Type in UserImage field and I am working with WPF</p>