W
William
i am using a dataset and a DataAdapter to update a table with the
following schema:
ResourceID
ProjectID
LastName
FirstName
Year
Nov
Dec
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
(ResourceID, ProjectID) is the primary key for the above "Forecast"
schema.
i got the following error message:
syntax error in INSERT INTO statement
my code:
private System.Windows.Forms.Button btnProjectView;
private System.Data.OleDb.OleDbConnection dcBUResourcesTrackingOriginal;
private System.Data.OleDb.OleDbConnection dcBUResourcesTracking;
private DataGridTableStyle dgrdTableStyle = new DataGridTableStyle();
private void btnGetData_Click(object sender, System.EventArgs e)
{
daForecast.Fill( dsResourceUsage );
}
private void btnUpdateData_Click(object sender, System.EventArgs e)
{
try
{
daForecast.Update( dsResourceUsage );
}
catch (Exception ex)
{
Console.WriteLine( ex.Message );
Trace.WriteLine( ex.Source );
Trace.WriteLine( ex.StackTrace );
}
}
private void btnProjectView_Click(object sender, System.EventArgs e)
{
frmProjectView projectView = new frmProjectView();
projectView.ShowDialog();
}
code for populating the dsResourceUsage dataset:
SELECT ResourceID, ProjectID, LastName, FirstName, Year, Nov, Dec,
Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct
FROM Forecast
I have tried setting
InsertCommand, UpdateCommand and DeleteCommand properties in the
DataAdapter object as follows:
INSERT INTO Forecast
(ResourceID, ProjectID, LastName, FirstName, Year,
Nov, Dec, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
UPDATE Forecast
SET ResourceID = ?, ProjectID = ?, LastName = ?, FirstName =
?, Year = ?, Nov = ?, Dec = ?, Jan = ?, Feb = ?, Mar = ?, Apr = ?, May =
?, Jun = ?, Jul = ?,
Aug = ?, Sep = ?, Oct = ?
WHERE (ProjectID = ?) AND (ResourceID = ?) AND (Apr = ? OR
? IS NULL AND Apr IS NULL) AND (Aug = ? OR
? IS NULL AND Aug IS NULL) AND (Dec = ? OR
? IS NULL AND Dec IS NULL) AND (Feb = ? OR
? IS NULL AND Feb IS NULL) AND ([First Name] = ? OR
? IS NULL AND [First Name] IS NULL) AND (Jan = ? OR
? IS NULL AND Jan IS NULL) AND (Jul = ? OR
? IS NULL AND Jul IS NULL) AND (Jun = ? OR
? IS NULL AND Jun IS NULL) AND ([Last Name] = ? OR
? IS NULL AND [Last Name] IS NULL) AND (Mar = ? OR
? IS NULL AND Mar IS NULL) AND (May = ? OR
? IS NULL AND May IS NULL) AND (Nov = ? OR
? IS NULL AND Nov IS NULL) AND (Oct = ? OR
? IS NULL AND Oct IS NULL) AND (Sep = ? OR
? IS NULL AND Sep IS NULL) AND (Year = ? OR
? IS NULL AND Year IS NULL)
DELETE FROM Forecast
WHERE (ProjectID = ?) AND (ResourceID = ?) AND (Apr = ? OR
? IS NULL AND Apr IS NULL) AND (Aug = ? OR
? IS NULL AND Aug IS NULL) AND (Dec = ? OR
? IS NULL AND Dec IS NULL) AND (Feb = ? OR
? IS NULL AND Feb IS NULL) AND (Jan = ? OR
? IS NULL AND Jan IS NULL) AND (Jul = ? OR
? IS NULL AND Jul IS NULL) AND (Jun = ? OR
? IS NULL AND Jun IS NULL) AND ([Last Name] = ? OR
? IS NULL AND [Last Name] IS NULL) AND (Mar = ? OR
? IS NULL AND Mar IS NULL) AND (May = ? OR
? IS NULL AND May IS NULL) AND (Nov = ? OR
? IS NULL AND Nov IS NULL) AND (Oct = ? OR
? IS NULL AND Oct IS NULL) AND (Sep = ? OR
? IS NULL AND Sep IS NULL) AND (Year = ? OR
? IS NULL AND Year IS NULL) AND (FirstName = ? OR
? IS NULL AND FirstName IS NULL)
Any suggestions/fix with regards to the "syntax error in INSERT INTO
statement" (occured when I call the btnUpdateData_Click() method) is
greatly appreciated.
William
following schema:
ResourceID
ProjectID
LastName
FirstName
Year
Nov
Dec
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
(ResourceID, ProjectID) is the primary key for the above "Forecast"
schema.
i got the following error message:
syntax error in INSERT INTO statement
my code:
private System.Windows.Forms.Button btnProjectView;
private System.Data.OleDb.OleDbConnection dcBUResourcesTrackingOriginal;
private System.Data.OleDb.OleDbConnection dcBUResourcesTracking;
private DataGridTableStyle dgrdTableStyle = new DataGridTableStyle();
private void btnGetData_Click(object sender, System.EventArgs e)
{
daForecast.Fill( dsResourceUsage );
}
private void btnUpdateData_Click(object sender, System.EventArgs e)
{
try
{
daForecast.Update( dsResourceUsage );
}
catch (Exception ex)
{
Console.WriteLine( ex.Message );
Trace.WriteLine( ex.Source );
Trace.WriteLine( ex.StackTrace );
}
}
private void btnProjectView_Click(object sender, System.EventArgs e)
{
frmProjectView projectView = new frmProjectView();
projectView.ShowDialog();
}
code for populating the dsResourceUsage dataset:
SELECT ResourceID, ProjectID, LastName, FirstName, Year, Nov, Dec,
Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct
FROM Forecast
I have tried setting
InsertCommand, UpdateCommand and DeleteCommand properties in the
DataAdapter object as follows:
INSERT INTO Forecast
(ResourceID, ProjectID, LastName, FirstName, Year,
Nov, Dec, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
UPDATE Forecast
SET ResourceID = ?, ProjectID = ?, LastName = ?, FirstName =
?, Year = ?, Nov = ?, Dec = ?, Jan = ?, Feb = ?, Mar = ?, Apr = ?, May =
?, Jun = ?, Jul = ?,
Aug = ?, Sep = ?, Oct = ?
WHERE (ProjectID = ?) AND (ResourceID = ?) AND (Apr = ? OR
? IS NULL AND Apr IS NULL) AND (Aug = ? OR
? IS NULL AND Aug IS NULL) AND (Dec = ? OR
? IS NULL AND Dec IS NULL) AND (Feb = ? OR
? IS NULL AND Feb IS NULL) AND ([First Name] = ? OR
? IS NULL AND [First Name] IS NULL) AND (Jan = ? OR
? IS NULL AND Jan IS NULL) AND (Jul = ? OR
? IS NULL AND Jul IS NULL) AND (Jun = ? OR
? IS NULL AND Jun IS NULL) AND ([Last Name] = ? OR
? IS NULL AND [Last Name] IS NULL) AND (Mar = ? OR
? IS NULL AND Mar IS NULL) AND (May = ? OR
? IS NULL AND May IS NULL) AND (Nov = ? OR
? IS NULL AND Nov IS NULL) AND (Oct = ? OR
? IS NULL AND Oct IS NULL) AND (Sep = ? OR
? IS NULL AND Sep IS NULL) AND (Year = ? OR
? IS NULL AND Year IS NULL)
DELETE FROM Forecast
WHERE (ProjectID = ?) AND (ResourceID = ?) AND (Apr = ? OR
? IS NULL AND Apr IS NULL) AND (Aug = ? OR
? IS NULL AND Aug IS NULL) AND (Dec = ? OR
? IS NULL AND Dec IS NULL) AND (Feb = ? OR
? IS NULL AND Feb IS NULL) AND (Jan = ? OR
? IS NULL AND Jan IS NULL) AND (Jul = ? OR
? IS NULL AND Jul IS NULL) AND (Jun = ? OR
? IS NULL AND Jun IS NULL) AND ([Last Name] = ? OR
? IS NULL AND [Last Name] IS NULL) AND (Mar = ? OR
? IS NULL AND Mar IS NULL) AND (May = ? OR
? IS NULL AND May IS NULL) AND (Nov = ? OR
? IS NULL AND Nov IS NULL) AND (Oct = ? OR
? IS NULL AND Oct IS NULL) AND (Sep = ? OR
? IS NULL AND Sep IS NULL) AND (Year = ? OR
? IS NULL AND Year IS NULL) AND (FirstName = ? OR
? IS NULL AND FirstName IS NULL)
Any suggestions/fix with regards to the "syntax error in INSERT INTO
statement" (occured when I call the btnUpdateData_Click() method) is
greatly appreciated.
William