Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Aug 24th, 2007, 4:11 PM   #1
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3 kruptof is on a distinguished road
DataAdapter syntax error

I having a bit of a trouble using the update method of the DataAdapter no matter what data i put into the dataset whenever i call that method on one of my tables i get an syntax error eventhough i am using the OleDbCommandBuilder, isn't this meant to generate the correct sql statements?

Here is my code;
        private void button1_Click(object sender, EventArgs e)
        {
            //connect the to the database
            OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb");
            connection.Open();

            //create the adapters
            OleDbDataAdapter channelAdapter = new OleDbDataAdapter("Select * From channel",connection);
            OleDbDataAdapter threadAdapter = new OleDbDataAdapter("Select * From thread", connection);
            OleDbDataAdapter postAdapter = new OleDbDataAdapter("Select * From post", connection);

            //create the command builders
            OleDbCommandBuilder channelCommandBuilder = new OleDbCommandBuilder(channelAdapter);
            OleDbCommandBuilder threadCommandBuilder = new OleDbCommandBuilder(threadAdapter);
            OleDbCommandBuilder postCommandBuilder = new OleDbCommandBuilder(postAdapter);
            DataSet ds = new DataSet();

            //create the schemas
            channelAdapter.FillSchema(ds, SchemaType.Source);
            ds.Tables["Table"].TableName = "channel";
            threadAdapter.FillSchema(ds, SchemaType.Source);
            ds.Tables["Table"].TableName = "thread";
            postAdapter.FillSchema(ds,SchemaType.Source);
            ds.Tables["Table"].TableName = "post";
            
            //create the relationships
            ds.Relations.Add("ChannelThread", ds.Tables["channel"].Columns["url"], ds.Tables["thread"].Columns["channel"]);
            ds.Relations.Add("ThreadPost", ds.Tables["thread"].Columns["url"], ds.Tables["post"].Columns["thread"]);

            //create the tables
            channelAdapter.Fill(ds,"channel");
            threadAdapter.Fill(ds, "thread");
            postAdapter.Fill(ds, "post");

            //below is just for testing
            DataRow ch = ds.Tables["channel"].NewRow();
            DataRow th = ds.Tables["thread"].NewRow();

            ch["url"] = "http://google.com";
            ch["title"] = "Google";
            ch["type"] = "podcast";
            ch["description"] = "some text here";

            th["url"] = "http://google.com/thread1.htm";
            th["title"] = "google thread 1";
            th["channel"] = "http://google.com";
            ds.Tables["channel"].Rows.Add(ch);
            ds.Tables["thread"].Rows.Add(th);
            channelAdapter.Update(ds, "channel");
            threadAdapter.Update(ds, "thread");
        }

The following error occurs on the last line:
Quote:
Syntax error in INSERT INTO statement
__________________
Quote:
When I was young it seemed that life was so wonderful,a miracle, oh it was beautiful, magical.
Now watch what you say or they'll be calling you a radical,a liberal, oh fanatical, criminal. Oh won't you sign up your name,we'd like to feel you're acceptable, respectable, oh presentable, a vegetable
kruptof is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Header file internal errors kruptof Coder's Corner Lounge 2 Jan 14th, 2007 1:12 PM
C# corruption!!! Kilo C++ 32 May 21st, 2006 8:44 PM
Masm rsnd Assembly 4 May 20th, 2006 9:05 PM
libraries matko C 1 Jan 22nd, 2006 2:12 PM
HELP please!!! hamacacolgante C 7 Nov 21st, 2005 5:36 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:00 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC