First make sure you have downloaded and installed the MySQL Connector/NET from the MySQL official website. In this article, I will use the Connector/NET version 6.1.
Then add MySql.Data namespace in Reference
Then you can use mysql in .net
now create a connection strin like this
class ConnectToMySql{
private MySqlConnection connection;
private void Initialize()
{
server = "localhost";
database = "connectcsharptomysql";
uid = "username";
password = "password";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
connection = new MySqlConnection(connectionString);
connection.Open();
}
}
Then
1 Create a MySQL command. 2 Assign a connection and a query to the command. This can be done using the constructor 3 using the Connection and the CommandText methods in the MySqlCommand class. 4 Create a MySqlDataReader object to read the selected records/data. 5 Execute the command. 6 Read the records and display them or store them in a list. 7 Close the data reader. 8 Close the connection.
I tooth this will help full for you . now you can start working on mysql in .NET
Best of luck