使用SQLiteDataAdapter更新保存数据库时出错

时间:2017-11-25 13:56:27

标签: c# database sqlite

我正在尝试在关闭表单时保存数据库。我没有数据集,我正在使用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' 我该如何解决这个问题?

0 个答案:

没有答案