title: Saving data in database using WPF
body: <p>I have a WPF Visual Studio 2010 application with a window containing 2 buttons and a datagrid. I want to modify the values of some row from datagrid and when the  "Set"-button is pushed the datagrid should be refreshed. The done changes should be saved only when a the Save button is pressed.    </p>
  
  <p>The refreshing works fine, but when I push the "save"-button I receive the following error message:    </p>
  
  <p><code>System.Data.UpdateException: An error occurred while updating the entries. See the inner exception for details. ---&gt; System.Data.SqlClient.SqlException: String or binary data would be truncated.
  The statement has been terminated.</code> </p>
  
  <p>My code at set button is:</p>
  
  <pre><code>myObjBase selected = this.dataGrid1.SelectedItem as nyObjBase;      
  myObj ist = new myObj ();    
  ist.field1= "";   
  ist.field2 = 22;  
  selected.myObj.Add(ist);    
  </code></pre>
  
  <p>and for the save button I have:      </p>
  
  <pre><code>dataSource.SaveChanges();                   
  </code></pre>