Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 22nd, 2005, 01:46 PM
Authorized User
 
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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;

 
Old February 22nd, 2005, 05:02 PM
Authorized User
 
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorted it!

I changed the 'position' column name and it works. This word must be reserved in MS Access even though it is not stated as reserved in any documentation I've read about reserved words.






Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in inserting data in gridview deb_kareng ASP.NET 2.0 Professional 0 August 22nd, 2007 02:07 AM
problem in inserting data monikanit ASP.NET 1.x and 2.0 Application Design 1 July 30th, 2007 02:48 AM
mysterious problem (data no inserting ) gratisaccount VB.NET 2002/2003 Basics 1 June 29th, 2006 08:48 AM
PROBLEM Inserting data into 2 tbls that r JOINED shyster1977 Classic ASP Databases 2 March 10th, 2005 10:40 AM
ODBC Data Adapter Configuration Wizard Problem TCantrell VB Databases Basics 0 February 27th, 2005 05:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.