C#代碼 using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using MySql.Data.MySqlClient; public partial class Default2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string query = "select * from guestbook"; MySqlConnection myConnection = new MySqlConnection("server=localhost;user id=root;password=;database=guestbook"); MySqlCommand myCommand=new MySqlCommand(query,myConnection); myConnection.Open(); myCommand.ExecuteNonQuery(); MySqlDataReader myDataReader = myCommand.ExecuteReader(); string bookres=""; while (myDataReader.Read()==true) { bookres+=myDataReader["id"]; bookres+=myDataReader["user"]; bookres += myDataReader["pass"]; } myDataReader.Close(); myConnection.Close(); lb1.Text = bookres; } }
2、MySQL安裝后默認是沒有客戶端工具的(像SQLServer的企業管理器,查詢分析器等),只是一個服務器存儲數據,為了方便你要再下載一個客戶端工具,有很多,推薦使用SQL Manager for MySQL,簡潔小巧,功能也強大。下載:http://www.sqlmanager.net/en/products/mysql/manager/download