OleDbDataAdapter UPDATE statement prompts INSERT INTO syntax error resolution

Source: Internet
Author: User
Tags exception handling
1. Use OleDbDataAdapter to update data to data in other tables based on the SELECT statement, as follows: public static bool Datasetupdatetable (String Selectsql,dataset ds) {T ry{
Oledbconnertion connection=new OleDbConnection ("link string"); connection.     Open ();     DataSet dsnew=new DataSet ();     OleDbDataAdapter adapter=new OleDbDataAdapter ("Selectsql", connection);      OleDbCommandBuilder ocb=new OleDbCommandBuilder (adapter); Ocb. Quoteprefix= "[";//This is to exclude the prompt "INSERT INTO syntax error" OCB when the update command is executed.     Quotesuffix= "]"; Adapter.     Fill (Dsnew, "DS"); object[] Obj=new object[ds. Tables[0].     Columns.count]; foreach (DataRow Dr in DS. Tables[0]. Rows) {Dr. Itemarray.copyto (obj,0);
Danew.tables[0]. Rows.Add (obj);
int Count=adapter. Update (Dsnew, "DS");
Dsnew.acceptchanges (); }
catch (System.Data.OleDb.OleDbException ex) {//exception handling
return false;
return true; 2, the implementation of the Update method prompts "insert INTO syntax error" to add the method of winning the red two words, namely OCB.     Quoteprefix= "["; Ocb. Quotesuffix= "]";

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.