Asp数据库编程

2018-12-29 18:13

实验项目名称 Asp.net数据库编程 一、实验目的和要求 1、掌握.net中ADO.net的原理 2、掌握连接SQL SERVER数据库的方法 3、掌握Sqldatacommand,Sqldataadapter 对象访问数据库的方法。 4、掌握记录查询,更新方法。 二、实验内容 1、教材P328,实验10.6。 2、完善上次实验所做的母版页,为登录按钮添加事件处理代码,完成登录功能;为注册按钮添加一个新网页,完成注册过程。 提示: (1)加载 using System.Data; using System.Data.SqlClient; (2)连接 SqlConnection mycon = new SqlConnection(constr); mycon.Open(); (3)查询 SqlCommand mycommand = new SqlCommand(sql语句, mycon); (4)读取 SqlDataReader myread = mycom.ExecuteReader(); (5) 数据适配器方法 SqlDataAdapter myadapter = new SqlDataAdapter(\语句\DataSet myset = new DataSet(); myadapter.Fill(myset, \自定义数据表名\ 三、实验步骤(此处粘贴所建网页的html编码和C#编码,只粘贴与本实验有关的) 1、 <%@ Page Language=\Inherits=\ 2、 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 System.Data.SqlClient; public partial class MasterPage : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) { Label1.Text = \今天是:\年MM月dd日\ if (!IsPostBack) { string constr = \Catalog=db_NetStore;Integrated Security=True\ SqlConnection mycon=new SqlConnection(constr); mycon.Open(); SqlCommand mysql=new SqlCommand(\ SqlDataReader myread=mysql.ExecuteReader(); myread.Read(); Label2.Text=myread[\ Image1.ImageUrl = myread[\ myread.Read(); Label3.Text=myread[\ Image2.ImageUrl = myread[\ mycon.Close(); } } protected void Button1_Click(object sender, EventArgs e) { string constr = \Catalog=db_NetStore;Integrated Security=True\ SqlConnection mycon = new SqlConnection(constr); mycon.Open(); SqlCommand mysql = new SqlCommand(\UserName = '\ SqlDataReader myread = mysql.ExecuteReader(); if (myread.Read()) { Session[\ Session[\ } else Label5.Text = \密码不对\ mycon.Close(); myread.Close(); } protected void Button2_Click(object sender, EventArgs e) { } protected void Button3_Click(object sender, EventArgs e) { Response.Redirect(\搜索结果.aspx?name=\ } } 四、实验结果(此处拷屏程序运行的结果) 1、 2、 五、结果分析与实验体会 评语: 成绩: 指导教师:张建科 2017 年5月25日


Asp数据库编程.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:设计概论试题

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: