using MySql.Data.MySqlClient;
namespace CSharp connects directly to MySQL
{
class Program
{
static void Main(string[] args)
{
string str = "server=127.0.0.1;port=3306;database=mygamedb;user=root;password =root;";
MySqlConnection conn = new MySqlConnection(str);
conn.Open();
Console.WriteLine("The database connection has been established");
conn.Close();
Console.ReadKey();
}
}
}
Note: To reference MySQL.Data.dll in vs first, the steps are as follows.
namespace CSharp connects directly to MySQL
{
class Program
{
static void Main(string[] args)
{
string str = "server=127.0.0.1;port=3306;database=mygamedb;user=root;password =root;";
MySqlConnection conn = new MySqlConnection(str);
conn.Open();
Console.WriteLine("The database connection has been established");
conn.Close();
Console.ReadKey();
}
}
}
QQ;848367854 Welcome to discuss