标签:blog http io ar os sp 文件 数据 on
1. 需要驱动
请下载 MySQLDriverCS-n-EasyQueryTools,版本自己选择就好
2.项目导入驱动
1)引用里增加
选择
图中浅色,ok。
3. 代码块
添加头文件
using MySQLDriverCS;
连接数据库代码
MySQLConnectionString tConnStr = new MySQLConnectionString("localhost","wxj","root", "", 3306);
MySQLConnection tConn = new MySQLConnection(tConnStr.AsString);
tConn.Open(); //打开连接
string tCmd = "SELECT * FROM wxj.stu;"; //命令语句
MySQLCommand cmd = new MySQLCommand(tCmd, tConn); //在定义的tConn对象上执行查询命令
MySQLDataReader tReader = cmd.ExecuteReaderEx();
if (tReader.Read()) // 一次读一条记录
{
Response.Write(tReader["name"].ToString());
}
tConn.Close();//重要!要及时关闭
tReader.Close();标签:blog http io ar os sp 文件 数据 on
原文地址:http://blog.csdn.net/cqs_experiment/article/details/41492121