How to Connect to MySQL in C#
http://dev.mysql.com/downloads/connector/net/
Here is the direct download link, but this version will change as there are updates:
http://dev.mysql.com/get/Downloads/Connector-Net/mysql-connector-net-6.9.8-noinstall.zip
Unzip the files in your downloads folder.
Right Click your project and add a reference:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
//name of your project mine was mysql_c
namespace mysql_c
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
MySql.Data.MySqlClient.MySqlConnection conn;
string myConnectionString;
myConnectionString = "server=localhost;uid=username;" +
"pwd=password;database=test;";
try
{
conn = new MySql.Data.MySqlClient.MySqlConnection();
conn.ConnectionString = myConnectionString;
conn.Open();
MessageBox.Show("Success, otherwise a window would have popped up with an error authenticating");
}
catch (MySql.Data.MySqlClient.MySqlException Error)
{
MessageBox.Show(Error.Message + " Error Did not Connectd");
}
}
}
}
Reference:
http://www.codeproject.com/Articles/43438/Connect-C-to-MySQL