C# establishes a direct connection to MySQL

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.
QQ;848367854 Welcome to discuss

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326762153&siteId=291194637