开发者

How do I connect to an mysql database in Visual Web Developer 2010?

It was my understanding that I should install the "ADO.NET Driver for MySQL (Connector/NET)", but it doesn't integrate with Visual Web Developer 2010, so I can't select a mysql-connection when creating a new connection from the Database Explorer.

There was VS 2008 Exp开发者_开发技巧ress installed and it configured it under installation. So I uninstalled VS 2008 Express and reinstalled the mysql connector without luck. Then I installed VS 2010 Express, but it didn't integrate there either.

Does anyone know what is wrong? How can I connect to an mysql database from Visual Web Developer 2010?


The ADO driver doesn't seem to integrate with Visual Web Developer Database explorer. You can however make a connection to a MySQL database by using ".Net Framework Data Provider for ODBC". You need to add a dsn reference first. Go to the Control Panel, go to Administration Tools and select Data Sources (ODBC). I added an User DSN by press the Add button. You should fine the MySQL ODBC 5.1 Driver in the list. Select it and you'll get the MySQL Connector/ODBC Data Source Configuration dialog box. Give a name to you Data Source Name (what ever you wnat to call it). Select TCP/IP Server. The server name was left blank since its on my local machine and the port was 3306. Enter the administrative user name the you used when you install MySQL for the User and enter the Password you used. You can then select the database you want. Assuming you installed the sample database, You'll see your database and the sample database in the drop down list. You can then press the Test button and it will verify that you can verify that the database connection works. Once you have that done you can my add a connection to you MySQL database in the Database Explorer by again selecting the ".Net Framework Data Provider for ODBC" You do that by changing the datasoure which bings up a Datasource dialogue box. Then select ".Net Framework Data Provider for ODBC" for the data provider.

In order to program and use mySQLConnection uou need to a a reference to it in Visual Web Developer 2010. To add the reference, click on the menu "Website" and select "Add reference ...". This will bring up the Add Reference dialog box. You would think that the refence would be available in the ".Net" tab, but it isn't. You need to select the "Browse" tab and an navigate to the the MySql assemblies. For me they were located in "C:/Program Files/MySQL/MySQL Connector Net 6.4.3/Assemblies./v4.0. By holding the "shift" or "ctrl" key down you can select all three dll's which are named" MySql.Data.dll, MySql.Data.Entity.dll and MySqlWeb.dll.


I am pretty sure you can use an ODBC connection to accomplish this, you just need to make sure you have the driver installed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜