游客发表

C# 链接MySQL数据库的实现步骤有哪些?

发帖时间:2025-11-05 06:56:53

C# 链接MySQL数据库的实现步骤有哪些?
复制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 = newMySQLConnection(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 = newMySQLDataAdapter(bb, conn);   DataSet ds = new DataSet();   sda.Fill(ds, "T");   this.GridView1.DataSource = ds;   this.GridView1.DataBind();   conn.close();   }   }   }   1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.

    热门排行

    友情链接