ASP.NET | 您所在的位置:网站首页 › asp页面连接数据库 › ASP.NET |
//html页面代码
=========================================================================== //后台代码 using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.IO;namespace 连接数据库{ public partial class Index : System.Web.UI.Page { DBHelper.DBHelperSQL help = new DBHelper.DBHelperSQL();//连接数据库,我用的是Web.config和DBHelper类连接的,建议你们自己写,不要复制 /// /// 加载数据 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GetNewLoad(); } } /// /// 方法 /// public void GetNewLoad() { help.Open(); System.Data.DataSet ds = help.ExecuteSQL(string.Format("SELECT * FROM Student",help.sqlConn)); //数据绑定 this.newlist.DataSource = ds; this.newlist.DataBind(); help.Colse(); } } } |
CopyRight 2018-2019 实验室设备网 版权所有 |