Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Microsoft.Data.Odbc gives me error

Status
Not open for further replies.

yahoo182

Programmer
Jul 5, 2005
70
CA
Hi there,
I am able to sccessfully open a connection to MySql db. but when I try to execute the following code, I get an error
Code:
string tableName="images";
OdbcConnection MyConnection = new OdbcConnection(MyConString);
MyConnection.Open();
OdbcCommand MyCommand = new OdbcCommand("DROP TABLE IF EXISTS"+tableName,MyConnection);

however, if I hardcode the table name like so, it works correctly.
Code:
OdbcCommand MyCommand = new OdbcCommand("DROP TABLE IF EXISTS images",MyConnection);
 
You need a space " " between EXISTS and your tableName
("DROP TABLE IF EXISTS"+tableName
should be
("DROP TABLE IF EXISTS "+tableName
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top