Reputation: 1716
I have the MySQL connector and I can see my MySQL database in the server explorer, I'm able to create tables and stuff... but when I try to access it through SqlConnection
or SqlCeConnection
I get error 40 or the one in the image
In English it means error while trying to access object reference data not defined to an instance of an object.
Upvotes: 1
Views: 108
Reputation: 9
can you please add Mysql.Data.MysqlClient; before that add reference to the source "Mysql.Data","Mysql.Web" Change "MySqlConnection" instead of "SqlConnection".
Upvotes: 1
Reputation: 9279
You are trying to use SqlConnection to connect MySql. This will not work this way. You need a Mysql.Data Library to use MySql Database.
Simply Every Sql (kind of class and method) prefix with 'My'. Like SqlConnection to MySqlConnection.
Upvotes: 1
Reputation: 754240
Well:
SqlConnection
is for Microsoft SQL Server onlySqlCeConnection
is for Microsoft SQL Server CE (Compact Edition) onlyYou need to use the MySqlConnection
to connect to MySQL !
Upvotes: 1