void updateTaxPayer()
{
DataRow[] ssnRow = dbSet.Tables["TrackingSheet"].Select("SSN = '" + ssn + "'");
ssnRow[0]["HAS SPOUSE"] = checkboxToString(chkSpouse.CheckState);
ssnRow[0]["SPOUSE SSN"] = txtSpouseSSN.Text;
ssnRow[0]["TNAME"] = txtName.Text;
ssnRow[0]["ADDRESS"] = txtStreetAddress.Text;
ssnRow[0]["CITY"] = txtCity.Text;
ssnRow[0]["STATE"] = cbxState.SelectedIndex.ToString();
ssnRow[0]["ZIP"] = txtZip.Text;
ssnRow[0]["HAS NEW ADDRESS"] = checkboxToString(chkNewAddress.CheckState);
ssnRow[0]["NEW ADDRESS"] = txtNewAddress.Text;
ssnRow[0]["NEW CITY"] = txtNewCity.Text;
ssnRow[0]["NEW STATE"] = cbxNewState.SelectedIndex.ToString();
ssnRow[0]["NEW ZIP"] = txtNewZip.Text;
ssnRow[0]["DATE FILED"] = txtDate.Text;
ssnRow[0]["SSN"] = txtSSN.Text;
dbAdapt.InsertCommand = cmdBuilder.GetInsertCommand(true);
dbAdapt.UpdateCommand = cmdBuilder.GetUpdateCommand(true);
dbAdapt.DeleteCommand = cmdBuilder.GetDeleteCommand(true);
dbAdapt.Update(dbSet,"TrackingSheet");
}
以上是我必须更新数据库的代码,但由于某种原因,当我尝试更新时,我收到更新命令的语法错误。我四处寻找,我不知道该怎么做。
我也试过 dbAdapt.Update(dbSet, "TrackingSheet"); 那也没有用。
确切的错误是:
System.Data.OleDb.OleDbException (0x80040E14): Syntax error in UPDATE statement.
at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
at trackingform.frmTrackingSheet.updateTaxPayer() in c:\Users\Anthony\Documents\Visual Studio 2012\Projects\trackingform\trackingform\frmTrackingSheet.cs:line 595
at trackingform.frmTrackingSheet.btnSave_Click(Object sender, EventArgs e) in c:\Users\Anthony\Documents\Visual Studio 2012\Projects\trackingform\trackingform\frmTrackingSheet.cs:line 506
第 595 行:dbAdapt.Update(dbSet,"TrackingSheet"); 第 506 行:updateTaxPayer();
其他声明:
dbAdapt = new OleDbDataAdapter();
cmdBuilder = new OleDbCommandBuilder(dbAdapt);
dbAdapt.SelectCommand = dbCmd;
dbSet = new DataSet("TrackingSheet");
dbAdapt.Fill(dbSet, "TrackingSheet");
有人有想法么?谢谢