Update db via MySqlCommandBuilder

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
Christiank
Posts: 2
Joined: Wed 20 Feb 2008 11:11

Update db via MySqlCommandBuilder

Post by Christiank » Wed 20 Feb 2008 11:33

Hi,
I use VS 2003 and your latest version of MyDirect.NET

I would like update my DB table (tbl_xy) with following commands:

[code]string sSQL = "SELECT * FROM tbl_xy";
MySqlCommand cmd = new MySqlCommand(sSQL, cn);
MySqlDataTable dt = new MySqlDataTable();
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
da.Fill(dt);

DataRow dr = dt.Rows[0];
dr["a"]= "b";
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
da.Update(dt);[/code]

The last line generate the following MySqlException:
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'cnString.tbl_xy SET a= 'b' WHERE ID = '1' at line 1"

where is the problem?
For example select, update, delete ... with ExecuteReader does work fine.[/code]

Alexey.mdr
Posts: 729
Joined: Thu 13 Dec 2007 10:24

Post by Alexey.mdr » Wed 20 Feb 2008 13:03

Please specify the version and edition of MyDirect .NET.
Please send me (alexeyman*crlab*com) your project to reproduce the problem.
Do not use third party components.

Christiank
Posts: 2
Joined: Wed 20 Feb 2008 11:11

Post by Christiank » Thu 21 Feb 2008 10:12

I have solved the problem.
For the CommandBulider its apparently a problem, if i have a '-' minus within my database name.

Best Regards

Alexey.mdr
Posts: 729
Joined: Thu 13 Dec 2007 10:24

Post by Alexey.mdr » Thu 21 Feb 2008 12:32

You may use this code:

Code: Select all

 mySqlCommandBuilder1.Quoted = true;

Post Reply