Microsoft SQLHelper的典型应用
[C#]
// 初始化连接字符串和命令文本
// 它们将构成用来存储和检索参数的键
const string CONN_STRING =
"SERVER=(local); DATABASE=Northwind; INTEGRATED SECURITY=True;"; string spName = "SELECT ProductName FROM Products " +
"WHERE CategoryID=@Cat AND SupplierID = @Sup";
// 缓存参数
SqlParameter[] paramsToStore = new SqlParameter[2];
paramsToStore[0] = new SqlParameter("@Cat", SqlDbType.Int);
paramsToStore[1] = new SqlParameter("@Sup", SqlDbType.Int);
SqlHelperParameterCache.CacheParameterSet(CONN_STRING,
spName,
paramsToStore);
// 从缓存中检索参数
SqlParameter[] storedParams = new SqlParameter[2];
storedParams = SqlHelperParameterCache.GetCachedParameterSet(
CONN_STRING, spName);
storedParams[0].Value = 2;
storedParams[1].Value = 3;
// 在命令中使用参数
DataSet ds;
ds = SqlHelper.ExecuteDataset(CONN_STRING,
CommandType.Text,
spName, storedParams);
[C#]
// 初始化连接字符串和命令文本
// 它们将构成用来存储和检索参数的键
const string CONN_STRING =
"SERVER=(local); DATABASE=Northwind; INTEGRATED SECURITY=True;"; string spName = "SalesByCategory";
// 检索参数
SqlParameter[] storedParams = new SqlParameter[2];
storedParams = SqlHelperParameterCache.GetSpParameterSet(
CONN_STRING, spName);
storedParams[0].Value = "Beverages";
storedParams[1].Value = "1997";
SQLHelper_电脑基础知识_IT/计算机_专业资料。SQLHelper--李飞 2012年1月9日 13:24 static class SQLHelper { //连接字符串,用App.config文件获取 private ...
SQLHelper_IT/计算机_专业资料。完整的SQLHelperusing System.Collections; using System.Collections.Specialized; using System.Data; using System.Data.SqlClient; ...
SqlHelper疑难点_计算机软件及应用_IT/计算机_专业资料。个人对sqlhelper的一些总结一、SqlDataAdapter、 DataSet 、DataTable、 DataRowCollection 、DataRow 的使用 ...
SqlHelper 代码、功能、用法介绍 代码、功能、数据访问组件 SqlHelper 数据访问组件是一组通用的访问数据库的代码,在所有项目中都可以用,一般不需要 修改。本节使用...
自己写的SqlHelper类_计算机软件及应用_IT/计算机_专业资料。方法重载,支持参数化语句using System; using System.Collections.Generic; using System.Linq; using ...
SQLHelper.cs经典代码_IT/计算机_专业资料 暂无评价0人阅读0次下载举报文档 SQLHelper.cs经典代码_IT/计算机_专业资料。比较简单实用的代码,希望对大家有帮助...
using System.Data.SqlClient; using System.Collections; namespace DAL { /// /// SqlHelper 类是对 SqlClient 类的再次封装 /// public abstract class...
微软SqlHelper类中文注释和使用方法_IT/计算机_专业资料。微软 SqlHelper 类中文注释和使用方法整理:飞晏博客;网址:http://www.feiyan.info/416.html。 和微软...
sqlhelper使用指南_IT/计算机_专业资料。sqlhelper使用指南摘要: 摘要:data access application block 是一个 .net 组件,包含优化的数据访问代码,可 以帮助用户调用...
//微软SQLHelper.cs类 中文版 using System; using System.Data; using System.Xml; using System.Data.SqlClient; using System.Collections; using System....
热门文档