2つのボタンとデータグリッドを含むウィンドウを備えたWPF Visual Studio 2010アプリケーションがあります。私は、DataGridからいくつかの行の値を変更したい、 "セット"ボタンが押されたときに、DataGridをリフレッシュする必要があります。完了した変更は、[保存]ボタンが押されたときにのみ保存されます。WPFを使用してデータベースにデータを保存する
爽やかが正常に動作しますが、私は "保存" を押すと、私は次のエラーメッセージが表示され-Button:
System.Data.UpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.SqlClient.SqlException: String or binary data would be truncated. The statement has been terminated.
をセットボタンでの私のコードは次のとおりです。
myObjBase selected = this.dataGrid1.SelectedItem as nyObjBase;
myObj ist = new myObj();
ist.field1= "";
ist.field2 = 22;
selected.myObj.Add(ist);
と保存ボタンの場合:
dataSource.SaveChanges();
ありがとうございます!これが問題でした! – user599977