All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
SQL Server机器上病毒扫描的注意事项_[SQL Server教程]
解决Ajax中文乱码问题_[AJAX教程]
asp.net计算网站访问量常用代码_[Asp.Net教程]
C#教程: 电子邮件的发送使用实例
SQL,server,2005的简单分页程序_[SQL,Server教程]
Web服务器IIS6的PHP最佳配置方法_php资料_编程技术
获取总记录数、总页数的存储过程_[Asp.Net教程]
如何在十天内学会php之第五天_php资料_编程技术
在Visual,C#中使用XML之编写XML_[Asp.Net教程]
asp程序页面出现超时已过期问题_mssql学习_编程技术
Reading number is top 10 pictures
YangYuYing and ZhengShaoQiu dance on the generous come interest dye-in-the-wood
西班牙山村小景2
The money of more than 100 countries and regions22
福利福利。。。。。。
The wise woman of chest1
Take you to walk into the most true north Korea rural4
去瑜伽会所面试的经过
The money of more than 100 countries and regions4
Household design of gorgeous series
Average female college students1
Download software ranking
C语言教程TXT
Tram sex maniac 2 (H) rar bag9
Ashlynn Video1
Eclipse 4.2.2 For Win64
Unix video tutorial7
dreamweaver8中文版
星际争霸1.08硬盘免安装版
Sora aoi, the maid, students' uniforms
jBuilder2006
卡丁车单机版
delv published in(发表于) 2014/1/27 6:50:53 Edit(编辑)
在asp.net2.0中使用存储过程_[Asp.Net教程]

在asp.net2.0中使用存储过程_[Asp.Net教程]

在asp.net2.0中使用存储过程_[Asp.Net教程]

  本文介绍了在asp.net2.0中使用存储过程的方法。


  以下是SQL中两个存储过程:



以下是引用片段:
  CREATE PROCEDURE dbo.oa_selectalluser
  AS
  select * from UserInfo
  GO
  CREATE PROCEDURE dbo.oa_SelectByID
  @id int
  AS
  select * from UserInfo where ID=@id
  GO


  一个是带参数的存储过程,一个是不带参数的存储过程.下面介绍怎么在VS2005中使用这两个存储过程.


  (一).不带参数的存储过程:



以下是引用片段:
  protected void Page_Load(object sender, EventArgs e)
  {
  if(!Page.IsPostBack)
  {
  //不带参数的存储过程的使用方法
  SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["oaConnectionString"].ToString());
  SqlDataAdapter da = new SqlDataAdapter();
  DataSet ds=new DataSet();
  da.SelectCommand = new SqlCommand();
  da.SelectCommand.Connection = conn;
  da.SelectCommand.CommandText = "oa_SelectAllUser";
  da.SelectCommand.CommandType = CommandType.StoredProcedure;
  da.Fill(ds);
  GridView1.DataSource = ds;
  GridView1.DataBind();
  }


  在页面中添加了一个GridView控件用来绑定执行存储过程得到的结果.


  (二).带参数的存储过程:



以下是引用片段:
  protected void btn_search_Click(object sender, EventArgs e)
  {
  //带参数的存储过程的使用方法
  SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["oaConnectionString"].ToString());
  SqlDataAdapter da = new SqlDataAdapter();
  DataSet ds = new DataSet();
  da.SelectCommand = new SqlCommand();
  da.SelectCommand.Connection = conn;
  da.SelectCommand.CommandText = "oa_SelectByID";
  da.SelectCommand.CommandType = CommandType.StoredProcedure;
  SqlParameter param = new SqlParameter("@id", SqlDbType.Int);
  param.Direction = ParameterDirection.Input;
  param.Value = Convert.ToInt32(txt_value.Text);
  da.SelectCommand.Parameters.Add(param);
  da.Fill(ds);
  GridView1.DataSource = ds;
  GridView1.DataBind();
  }


  同样,在页面中添加了一个GridView控件用来绑定执行存储过程的结果,另外,在页面中还添加了一个textbox控件和一个BUTTON按钮,上面的执行存储过程是放在按钮的onclick事件中的.textbox控件用来接收存储过程的参数.







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.