Page 1 of 1

Update db via MySqlCommandBuilder

Posted: Wed 20 Feb 2008 11:33
by Christiank
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]

Posted: Wed 20 Feb 2008 13:03
by Alexey.mdr
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.

Posted: Thu 21 Feb 2008 10:12
by Christiank
I have solved the problem.
For the CommandBulider its apparently a problem, if i have a '-' minus within my database name.

Best Regards

Posted: Thu 21 Feb 2008 12:32
by Alexey.mdr
You may use this code:

Code: Select all

 mySqlCommandBuilder1.Quoted = true;