C#连接MySql
1.從http://prdownloads.sourceforge.net/mysqldrivercs/MySQLDriverCS-n-EasyQueryTools-3.0.18.exe?download上下載MySQLDriverCS.?然后安裝。
2.從安裝目錄中把MySQLDriverCS.dll.添加到.net的組件?
1 public void Connect_Net() 2 { 3 MySQLConnection mycn = new MySQLConnection(new MySQLConnectionString("localhost", "test", "root", "root", 3306).AsString); 4 mycn.Open(); 5 MySQLCommand mycm = new MySQLCommand("SELECT * FROM user_message", mycn); 6 MySQLDataReader reader = mycm.ExecuteReaderEx(); 7 try 8 { 9 while (reader.Read()) 10 { 11 str = reader.GetString(0) + reader.GetString(1); 12 textBox2.AppendText(str); 13 } 14 } 15 catch (Exception e) 16 { 17 str = e.ToString(); 18 } 19 reader.Close(); 20 mycn.Close(); 21 }
?
?
轉載于:https://www.cnblogs.com/wuyihong/archive/2012/06/09/2543529.html
總結
- 上一篇: 一个“复制/删除”方式的滚动
- 下一篇: 普洱茶多少钱一斤啊?