| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
wen5
10年前发布

C#使用MySQLDriverCS连接MySQL数据库的代码片段

MySQLDriverCS下载地址: http://go.rritw.com/sourceforge.net/projects/mysqldrivercs/

static void Main(string[] args)          {              MySQLConnection conn = new MySQLConnection(new MySQLConnectionString("127.0.0.1","student", "root", "root",3306).AsString);              conn.Open();                 MySQLCommand cmd = new MySQLCommand("select * from stuinfo", conn);              DbDataReader reader = cmd.ExecuteReader();              while (reader.Read())              {                  Console.WriteLine(reader.GetString(0) + " " + reader.GetString(1) + " " + reader.GetString(2) + " " + reader.GetString(3));//读出查询的结果                }              Console.ReadKey();              reader.Close();              conn.Close();//关闭连接            }