2010-11-10 76 views

回答

0

安裝程序檢查的.Net 3.5或2.0瑪貝=

0

你應該使用MySQL連接器/網絡6.3.5可在提到它會工作位置(http://dev.mysql.com/downloads/connector/net/)

0

我通過從一個現有項目複製/粘貼,然後消毒它...所以它沒有被編譯和測試,但它拼湊在一起你明白了。所以下面是一些示例代碼,以幫助您開始:

using MySql.Data.Types; 
using MySql.Data.MySqlClient;  

private void Function() 
    { 
        //Set up connection, SqlHost/etc are classwide and declared elsewhere: 
        MySql connection = new MySqlConnection("SERVER=" + SqlHost + ";DATABASE=" + DatabaseName + ";UID=" + user + ";PASSWORD=" + password + ";pooling=false"); 

        //Setup query: 
        MySqlCommand command = connection.CreateCommand(); 
        MySqlDataReader Reader;  
        command.CommandText = "your query here"; 

        //Connect to relation system and execute query: 
        connection.Open(); 
        Reader = command.ExecuteReader(); 
        while(Reader.Read()) 
        { 
         MessageBox.Show("here's a row from the query response: " + Reader[0].ToString()); 
        } 

        //Clean up: 
        connection.Close(); 
        Reader.Close(); 
    }