ASP.NET链接MySQL

来源:互联网 发布:淘宝能买什么 编辑:程序博客网 时间:2024/06/08 08:27

1.需要有Mysql.Data.dll,有区分版本的,这个要注意下


2.连接字符串代码

using MySql.Data.MySqlClient;namespace ConnectMySql{    class Class1    {        public MySqlDataReader GetData()        {            string connection = "server=localhost;user id=root;password=123456;database=ABC; pooling=true;";            MySqlConnection conn = new MySqlConnection(connection);            string sqlQuery = "SELECT * FROM Article";            MySqlCommand comm = new MySqlCommand(sqlQuery, conn);            conn.Open();            MySqlDataReader dr = comm.ExecuteReader();            conn.Close();            return dr;        }    }}

内容引用来源:http://www.tuicool.com/articles/yyUFfe
0 0
原创粉丝点击