Wrox Programmer Forums
|
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 November 25th, 2004, 02:56 PM
Registered User
 
Join Date: Nov 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default I Need Help!!

I have a problem in the following codes:
When it run, an Exception was thrown : INSERT INTO syntax error
the wrong line is printed red .



...

OleDbConnection mConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " +
                    @"Data Source=database\csmng.mdb;");
                OleDbDataAdapter da = new OleDbDataAdapter();
                da.SelectCommand = new OleDbCommand("select * from T_Course",mConn);
                OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
                mConn.Open();
                DataSet ds = new DataSet();
                da.Fill(ds,"T_Course");
                DataTable dt = ds.Tables["T_Course"];
                dt.Columns[0].AutoIncrement = true;
                DataRow row = dt.NewRow();
                row["College"] = "a string";
                row["Major"] = "a string";
                row["Grade"] = "a string";
                ds.Tables["T_Course"].Rows.Add(row);
                da.Update(ds,"T_Coures");
...

 
Old November 30th, 2004, 10:32 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Although I have not used the CommandBuilder classes, your code looks incomplete. You set up a new command builder class, but I don't see it used anywhere. So the data adapter 'da' doesn't have an update command to use when you call the .Update() method.









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