简体   繁体   中英

Using MySQL with Visual Studio (c#)

I am currently programming software to manage a MySQL database. Regularly I am a Java developer, but as far as c# is not a big deal when you are farmiliar with Java and Visual Studio greatly supports MySQL, I tried doing it this way. I installed the official 'development kit' from MySQL to develope in Visual Basic and it is indeed very easy to connect to a database and fill a textbox with some information etc. Lets come to my problems in detail now:

The first problem is, that I cannot find a way to draw specific fields from my database in a table. I can draw a whole table in a gridviewtable, but I only need a few fields from my database. But that is not a big deal, I might find a solution on this one.

The bigger problem is, that I cannot use the term "using MySQL;" and so I'm not able to use single SQL statements in my c# code. I installed everything properly in my opinion and can't find any problems. Even after installing everything again, I don't know why this is not working. Drag and drop things from Visual Studio works with no problems as I mentioned above.

Has someone a hint or solved the same problem already?

I am using Visual Studio Ultimate 2013 and MySQL 5.6 (I think it is 5.6).

Thanks in advance,

Besplash

Edit: It was enough to restart the PC. Im sorry.

In MySql installer, you should see an item called Connector/NET. You need to make sure that is installed. After that is installed, right click on your project, click add reference. On the new window that opens, hit the Extensions button on the left side. Scroll down till you see MySql.Data . You will most likely have multiple versions of it, so mouse over them to find the right version for your .Net (it will be in the file location after Assemblies\\... . Click hit, hit ok, then you should be able to add the using MySql.Data.MySqlClient to your code files.

Install Connector/Net and add reference to mysql.dll. There is also alternative solution - connect over ODBC. Use OdbcConnection class and define ODBC DSN in Control Panel connected to MySQL.

在VS中,启动NuGet窗口,然后在线搜索MySql,您将找到MySql AB或Oracle制造的所需组件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM