.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

C# Connectivity with MYSQL using ODBC

Posted By:Lakhan Pal Garg       Posted Date: September 11, 2009    Points: 10    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  

First of all Downlaod MyODBC-3.51.06.exe and install.

Now add the following lines of code to connect it to the DataBase.

string sConString = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost;DATABASE=Lakhan; UID=root; PASSWORD=; OPTION=3";
OdbcConnection oConnection = new OdbcConnection(sConString);
string sSQL = "SELECT * FROM tdTest";
OdbcDataAdapter oDataAdapter = new OdbcDataAdapter(sSQL, oConnection);
DataSet oDataSet = new DataSet();

This piece of code will return a DataSet that contains data from tdTest Table.


Further Readings:

Author: Venkat         Company URL: http://www.dotnetspark.com
Posted Date: September 11, 2009

Good one..Lakhan..

I have seen you have recommended "MyODBC-3.51.06.exe" is it better than native ODBC provider available in .NET Framework?

I have used .NET connector is available for MYSQL and is available for download


Author: Lakhan Pal Garg         Company URL: http://www.dotnetspark.com
Posted Date: September 12, 2009

Hi Venkat-

i tried that too and but that was not working in this case. so i tried out this..

Thanks & Regards
Lakhan Pal Garg

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend