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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with C# and MySQL: how to connect them

Status
Not open for further replies.

carlossan

Programmer
Dec 10, 2005
18
CA
Hello,

I am using VS2005, MySQL 5.0.24a, and I downloaded MySQL Visual Studio Connector 5, and the MySQL Visual Studio Plugin 1.0.

Using VS server explorer I can see my database and my tables (even the content of them).

What else do I have to do to connect a C# application with that database ?

I see that I cannot just drag and drop as it can be done with Microsoft SQL server (or ar least I don't know how to do it), so I'm guessing the connection between my c# application and the mysql database is programmatically done using ODBC. Am I right ?

Can somebody point me to some code/resource to learn how to do that connection ?

Regards,

Carlos
 
I think when I was trying to make the connection - this tutorial helped me make the connection. Here's a phrase from the tutorial that will probably help you. This says VB.Net but should work for C#.

"Before we can use Connector/NET with Visual Basic, we need to add a reference to our project. By adding a reference, we are telling VB.NET where to find MySQL Connector/NET in order to access the objects and methods of Connector/NET.

To add a reference, choose the Add Reference… option of the Project menu. Choose the Browse tab and browse to the Connector/NET installation, typically located at C:\Program Files\MySQL\MySQL Connector Net n.n.n\bin\.NET N.N (The path may vary depending on the version number of Connector/NET and the .NET Framework). Choose the MySql.Data.dll file and Connector/NET will be added to your project. You will also need to add a reference to System.Data.dll."

Here's a link to the tutorial:
 
Thanks Richard,

I'm having some success now: I can see the data from the database in a text box. I'm now trying to see it in a DataGridView control...still with problems, but with some tests left to do.

Carlos
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top