做项目时写的数据库操作类。SqlHelper.cs(三)
2009-07-12 16:40
495 查看
ExcuteReader.apx.cs(示例)
1 using System;
2 using System.Data;
3 using System.Configuration;
4 using System.Collections;
5 using System.Web;
6 using System.Web.Security;
7 using System.Web.UI;
8 using System.Web.UI.WebControls;
9 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11 using System.Data.SqlClient;
12
13 public partial class ExcuteReader : System.Web.UI.Page
14 {
15 protected void Page_Load(object sender, EventArgs e)
16 {
17
18 }
19
20 protected void btnExecuteReader_Click(object sender, EventArgs e)
21 {
22 //获取要执行的命令
23 string sql = txtSql.Text;
24
25 using (SqlConnection conn = new SqlConnection (SqlHelper.ConnectionStringLocalTransaction ))
26 {
27 SqlDataReader myDr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, sql, null);
28
29 //将结果赋予DataList,作为其数据源
30 dtst.DataSource = myDr;
31
32 //绑定数据源
33 dtst.DataBind();
34 }
35 }
36 }
37
1 using System;
2 using System.Data;
3 using System.Configuration;
4 using System.Collections;
5 using System.Web;
6 using System.Web.Security;
7 using System.Web.UI;
8 using System.Web.UI.WebControls;
9 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11 using System.Data.SqlClient;
12
13 public partial class ExcuteReader : System.Web.UI.Page
14 {
15 protected void Page_Load(object sender, EventArgs e)
16 {
17
18 }
19
20 protected void btnExecuteReader_Click(object sender, EventArgs e)
21 {
22 //获取要执行的命令
23 string sql = txtSql.Text;
24
25 using (SqlConnection conn = new SqlConnection (SqlHelper.ConnectionStringLocalTransaction ))
26 {
27 SqlDataReader myDr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, sql, null);
28
29 //将结果赋予DataList,作为其数据源
30 dtst.DataSource = myDr;
31
32 //绑定数据源
33 dtst.DataBind();
34 }
35 }
36 }
37
相关文章推荐
- 做项目时写的数据库操作类。SqlHelper.cs(五)
- 做项目时写的数据库操作类。SqlHelper.cs(六)
- 做项目时写的数据库操作类。SqlHelper.cs(一)
- 做项目时写的数据库操作类。SqlHelper.cs(二)
- 做项目时写的数据库操作类。SqlHelper.cs(四)
- Sqlhelper.cs--数据库操作类
- 为公司一个项目写的一个数据库操作类,使用了SQL Relay
- 利用SqlHelper.cs实现Web程序对数据库的增、删、改等操作
- 数据操作类 SQLHelper.cs
- 个人学习代码保存:例2.小项目的sql简单的数据库操作类
- 公共的数据库访问访问类 SqlHelper.cs
- 利用SqlHelper.cs实现Web程序与数据库的连接
- 数据操作类 SQLHelper.cs
- 利用SqlHelper.cs实现Web程序与数据库的连接
- 数据操作类 SQLHelper.cs
- 利用SqlHelper.cs实现Web程序与数据库的连接
- SqlServerHelper.cs数据库操作
- 利用SqlHelper.cs实现Web程序对数据库的增、删、改等操作
- 利用SqlHelper.cs实现Web程序与数据库的连接
- C#数据库编程 之 DbHelper数据操作类【DBHelper.CS】