Add reference to MySQLDriverCS. dll,: http://downloads.sourceforge.net/mysqldrivercs/MySQLDriverCS-n-EasyQueryTools-4.0.1-DotNet2.0.exe
1: using System;
2: using System.Web.UI.WebControls;
3: using System.Data;
4: using MySQLDriverCS;
5:
6: public partial class _Default : System.Web.UI.Page
7: {
8: protected void Page_Load(object sender, EventArgs e)
9: {
10: MySQLConnection conn = null;
11: conn = new MySQLConnection(new MySQLConnectionString("Localhost", "CNPCEdit", "root", "").AsString);
12: conn.Open();
13: MySQLCommand commn = new MySQLCommand("set names gb2312", conn);
14: commn.ExecuteNonQuery();
15: string sql = "select * from Checklist where family='Apiaceae'";
16: MySQLDataAdapter mda = new MySQLDataAdapter(sql, conn);
17: DataSet ds = new DataSet();
18: mda.Fill(ds, "Checklist");
19: grdFamily.DataSource = ds;
20: grdFamily.DataBind();
21: conn.Close();
22: }
23: protected void grdFamily_PageIndexChanging(object sender, GridViewPageEventArgs e)
24: {
25: grdFamily.PageIndex = e.NewPageIndex;
26: }
27: }