我正在尝试在关闭表单时保存数据库。我没有数据集,我正在使用bindingsource。这是我的功能:
private void SaveData()
{
try
{
sqliteDataAdapter.Update(dataTable);
}
catch (ConstraintException)
{
DataRow[] rowErrors = dataTable.GetErrors();
System.Diagnostics.Debug.WriteLine("YourDataTable Errors:"
+ rowErrors.Length);
for (int i = 0; i < rowErrors.Length; i++)
{
System.Diagnostics.Debug.WriteLine(rowErrors[i].RowError);
foreach (DataColumn col in rowErrors[i].GetColumnsInError())
{
System.Diagnostics.Debug.WriteLine(col.ColumnName
+ ":" + rowErrors[i].GetColumnError(col));
}
}
}
}
我收到错误:System.Data.dll中的'System.InvalidOperationException' 我该如何解决这个问题?