using MySQL.Data.MySQLClient; namespace Discuz { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { this.Bind(); } } public void Bind() { string MySQLString = "User Id=dis;pwd=sa;Host=1.2.3.4;Port=6033;Database=dis;Character Set=utf8"; MySQLConnection conn = new MySQLConnection(MySQLString); conn.Open(); string bb = "SELECT p.author, p.message FROM cdb_threads AS t INNER JOIN cdb_posts AS p ON t.tid = p.tid where t.fid = 34 and digest !=0"; MySQLDataAdapter sda = new MySQLDataAdapter(bb, conn); DataSet ds = new DataSet(); sda.Fill(ds, "T"); this.GridView1.DataSource = ds; this.GridView1.DataBind(); conn.close(); } } }