首页 > 代码库 > C# BulletedList 绑定 Mysql
C# BulletedList 绑定 Mysql
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using MySql.Data.MySqlClient; public partial class page1 : System.Web.UI.Page { string connStr = String.Format( "server={0};user id={1};password={2};database={3};port={4};pooling=false;charset=utf8", "192.168.1.3", "root", "1234567", "test", 3306); public MySqlConnection con = new MySqlConnection(); public MySqlDataAdapter da; public MySqlCommandBuilder cb; public MySqlCommand cmd; public MySqlDataReader dr; protected void Page_Load(object sender, EventArgs e) { con.ConnectionString = connStr; try { con.Open(); Label1.Text = "连接 Mysql 成功!"; string sql = "select * from test"; da = new MySqlDataAdapter(sql, con); DataSet mydataset = new DataSet(); da.Fill(mydataset, "test"); BulletedList1.DataSource = mydataset.Tables["test"]; BulletedList1.DataTextField = "Name"; BulletedList1.DataValueField = "link"; BulletedList1.DataBind(); } catch { Label1.Text = "连接 Mysql 失败!"; } } }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。