Problem inserting with data adapter
Hello,
I am trying to perform an insert with a data adapter but keep getting this error:
Exception Details: System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.
Source Error:
Line 202:
Line 203:
Line 204: adapter.Update(dataSet,"[pages]");
Line 205:
Line 206: int pageId =0;
I've done other inserts with success in the same way and I'm pretty sure I'm using no words that are reserved by Microsoft access. Any ideas? I've posted the code below
Thanks
Charlie.
OleDbConnection connection = getConnection();
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT [parent_id],[position],[page_title],[body_text],[access_key],[image_id],[image_alt],[show_links],[page_type] FROM [pages]",connection);
adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter);
DataSet dataSet = new DataSet();
connection.Open();
adapter.Fill(dataSet,"[pages]");
DataTable dataTable = dataSet.Tables["[pages]"];
DataRow row = dataTable.NewRow();
row["parent_id"] = page.parentId;
row["position"] = page.position;
row["page_title"] = page.pageTitle;
row["body_text"] = page.bodyText;
row["access_key"] = page.accessKey;
row["image_id"] = page.imageId;
row["image_alt"] = page.imageAlt;
row["show_links"] = page.showLinks;
row["page_type"] = 0;
dataTable.Rows.Add(row);
adapter.Update(dataSet,"[pages]");
int pageId =0;
if( !row.IsNull("page_id") )
pageId = (int)row["page_id"];
connection.Close();
return pageId;
|