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