购物网站设计-Web实验报告.docVIP

  • 36
  • 0
  • 约7.36千字
  • 约 7页
  • 2019-08-03 发布于浙江
  • 举报
J I A N G S U U N I V E R S I T Y 班 班 级: 学生姓名: 学 号: 完成时间:2014年11月18日 购物网站设计报告 购物网站设计报告 一:设计要求 购物车包含注册页面、登录页面、购物页面、购物车四个页面。 在购物页面中,将页面信息与数据库绑定,直接将数据库中的内容显示到网页上。另外,对“名称”设计超链接,点击进入商品的详细信息介绍页面。 网站美观大方 实现效果 登录页面 注册页面 购物页面 购物车 主要代码 登录页面与数据库连接 protected void Button2_Click(object sender, EventArgs e) { string connstr = @Data Source=XIAOZHENZHEN-PC;Initial Catalog=login;Integrated Security=True; StringBuilder sb = new StringBuilder(); sb.Append(select count (); sb.Append(); sb.Append(TextBox1.Text); sb.Append() from userinfo where password=); sb.Append(TextBox2.Text); using (SqlConnection conn = new SqlConnection(connstr)) { SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = sb.ToString(); conn.Open(); int num = (int)cmd.ExecuteScalar(); if (num 0) { Response.Redirect(shop.aspx); } else { Response.Write(账号密码错误); } } } 注册页面与数据库连接 protected void Button1_Click(object sender, EventArgs e) { string connstr = @Data Source=XIAOZHENZHEN-PC;Initial Catalog=login;Integrated Security=True; StringBuilder sb = new StringBuilder(); sb.Append(insert into userinfo(username,password,shenfen,name,sex,birthday,telephone)values(); sb.Append();sb.Append(TextBox1.Text);sb.Append(); sb.Append(,); sb.Append();sb.Append(TextBox2.Text);sb.Append();sb.Append(,); Response.Write(sb.ToString()); using (SqlConnection conn = new SqlConnection(connstr)) { conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = sb.ToString(); int num =(int) cmd.ExecuteNonQuery(); int count =(int)cmd.ExecuteNonQuery(); if (count 0) { Response.Redirect(Defaul

文档评论(0)

1亿VIP精品文档

相关文档