黑马程序员_带参数存储过程入门学习
来源:互联网 发布:天猫 淘宝商城床单人床 编辑:程序博客网 时间:2024/04/29 19:34
今天学习了存储过程入门,其实感觉储存过程没有什么,就是把SQL语句集合到一起了,
html页面代码功能
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblShow" runat="server"></asp:Label>
<asp:Button ID="btnShow" runat="server" Text="Test" onclick="btnShow_Click"/>
<table border="1" align="center" width="600" style="text-align:center;">
<asp:Repeater ID="repeater" runat="server">
<HeaderTemplate>
<tr style="background-color:skyblue;color:white;">
<td style="width:90px;">
用户编号
</td>
<td style="width:90px;">
用户名
</td>
<td style="width:90px;">
用户密码
</td>
<td style="width:90px;">
年龄
</td>
<td style="width:90px;">
性别
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td style="width:90px;">
<%#Eval("ID") %>
</td>
<td style="width:90px;">
<%#Eval("UserName") %>
</td>
<td style="width:90px;">
<%#Eval("UserPass") %>
</td>
<td style="width:90px;">
<%#Eval("Age") %>
</td>
<td style="width:90px;">
<%#Eval("Role") %>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</div>
</form>
</body>
</html>
后台cs代码测试
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnShow_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Server=.;database=db_test;pwd=;uid=sa;");
SqlParameter para = null;
int startAge = 21;
DataTable dt = new DataTable();
SqlDataAdapter sda=new SqlDataAdapter("db_test1",con);
para=new SqlParameter("@startAge",startAge);
sda.SelectCommand.Parameters.Add(para);
sda.SelectCommand.CommandType = CommandType.StoredProcedure;
try
{
con.Open();
sda.Fill(dt);
repeater.DataSource = dt;
repeater.DataBind();//数据绑定
con.Close();
}
catch (Exception ee)
{
Response.Write("<script>alert('出现了异常!')</script>");
}
}
}
数据库存储过程
CREATE procedure db_test1
@startAge int
as
select * from tb_test where Age>@startAge order by Age Desc
GO
---------------------- Windows Phone 7手机开发、.Net培训、期待与您交流! ----------------------详细请查看:http://net.itheima.com/
- 黑马程序员_带参数存储过程入门学习
- 黑马程序员_存储过程入门
- 存储过程参数不能带“_”前缀
- 黑马程序员_java入门_可变参数
- 黑马程序员_学习日记72_724ASP.NET(ViewState、Cookie、Session、登录、分页存储过程)
- 带参数存储过程
- 黑马程序员学习日记----通用存储过程
- 黑马程序员_.Net如何使用存储过程
- 黑马程序员--存储过程
- 调用带参数存储过程
- 带输出参数存储过程
- 存储过程带in参数
- 存储过程带返回参数
- 带参数的存储过程
- 带参数的存储过程
- 黑马程序员_学习日记5_ADO.Net入门1
- 黑马程序员_学习日记6_ADO.Net入门2
- 黑马程序员--分页存储过程
- OSB实战开发【二】配置 配置OSB的域模版
- 黑马程序员_存储过程入门
- 文档模式DOCTYPE
- 时间管理(详细说明)
- AM1808 开发记录(一)
- 黑马程序员_带参数存储过程入门学习
- 美国各州名记缩写
- 简单贪吃蛇的编程设计
- 测试方案
- 反射
- 用cocos2d-x做一个简单的windows phone 7游戏----系列文章
- linux进程学习笔记一--进程控制
- Android 判断是否得到 root权限
- Dom4j 解析XML (初级入门)