How To Use MySql Connector Net

First we need to create a windows form  a project in Visual Studio you can choose from C# or VB.  Once we have a project we just need to right-click in reference then select Add Reference

how-to-use-mysql-in-visual-studio
Once we are in the Reference Manager window we just need to click Assemblies->Extensions then select MySQL.Data and MySql.Data.Entiry then click Ok button.
how-to-use-mysql-in-visual-studio

 

On our code we just need to create a ConnectionString “Server=[server ip];Port=[mysql port no];Database=[database name];Uid=[mysql username];Pwd=[mysql password];”

Here is a sample code for that will records from table [pl_make]


string _conStr = "Server=127.0.0.1;Port=3306;Database=ddtrax;Uid=root;Pwd=password;";

MySqlConnection _con = new MySqlConnection(_conStr);
DataTable _table = new DataTable();
MySqlDataAdapter _adp = new MySqlDataAdapter("select * from pl_make", _con);
_adp.Fill(_table);


Dim  _conStr as String = "Server=127.0.0.1;Port=3306;Database=ddtrax;Uid=root;Pwd=dd2015;"

Dim _con as MySqlConnection = new MySqlConnection(_conStr)
Dim _table as new DataTable()
Dim _adp as new MySqlDataAdapter("select * from pl_make", _con)
_adp.Fill(_table)

Liked it? Take a second to support denricdenise on Patreon!

You may also like...