.NET ez 2012-06-27
首先必須下載 MySQL Connector Net 程式:
官方下載網址:http://dev.mysql.com/downloads/connector/net/
本地下載:mysql-connector-net-6.5.4-noinstall
讀取資料表:
using MySql.Data.MySqlClient; MySqlConnection con = new MySqlConnection(String.Format("Server={0};Port={1};Database={2};Uid={3};Pwd={4};connection timeout={5};use compression={6};pooling={7};min pool size={8};max pool size={9};", "127.0.0.1", "3306", "Database", "UserID", "Password", "5", "True", "False", "5", "100")); con.Open(); DataSet DS = new DataSet(); MySqlDataAdapter DT = new MySqlDataAdapter("SELECT * FROM XXXX", con); DT.SelectCommand.CommandTimeout = 60; DT.Fill(DS); DT.Dispose(); con.Close(); con.Dispose(); con = null;
新增和修改就不寫瞜!只需要把 SQL 指令改掉即可!
標籤: .NET