MySQL with .NET and prefix problems

 

Heads up to MySQL and .NET developers.  MySQL appears to have a bug in the .NET connector code.  If you’re using typed datasets and drag a table from the server explorer onto your data set designer, it will appear to work (and it does), but it also generates SQL code with the name of the database hard coded in front of the table name.  This is not a problem if the name of your development database is the same as your test and production databases.

If your production or test database has a different name than your development database (the database you were connected to when you dragged the table or other DB object from server explorer onto your data set design surface), then when you change your connection string to use your test or production database with a different name, it will fail, even if you explicitly specify the name of your production or test database in your connection string, the hard coded development database name is STILL in the generated SQL and your code will fail to execute.

The solution is to manually remove the hard coded database name prefix from all of the generated SQL in your typed data set.

Leave a Reply