ASP.NET 您所在的位置:网站首页 asp页面连接数据库 ASP.NET

ASP.NET

2023-08-12 01:33| 来源: 网络整理| 查看: 265

//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 实验室设备网 版权所有