文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > SQLHelper类
侵权投诉

SQLHelper类

微软提供的VS与SQL数据库连接类(C#语言)。

//===============================================================================
// This file is based on the Microsoft Data Access Application Block for .NET
// For more information please go to
// doc.guandang.net
//===============================================================================
/*----------------------------------------------------------------

//

// public static int ExecuteNonQuery(string commandText, params SqlParameter[] parameter)
// public static object ExecuteScalar(string commandText, params SqlParameter[] parameter)
// public static SqlDataReader ExecuteReader(string commandText, params SqlParameter[] parameter)
// public static DataTable ExecuteTable( string commandText, params SqlParameter[] parameter)
//
// 修改标识:
// 修改描述:
//----------------------------------------------------------------*/

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Collections;

namespace DAL
{

/// <summary>
/// SqlHelper 类是对 SqlClient 类的再次封装
/// </summary>
public abstract class SQLHelper
{
/// <summary>
/// 默认的数据库连接字符串
/// </summary>
//public static string CONN_STRING = ConfigurationSettings.AppSettings["LandlordManagerConnectionString"].ToString();
public static string CONN_STRING = ConfigurationManager.ConnectionStrings["conStr"].ToString();

// 用来缓存参数的哈希表
private static Hashtable c_ParmCache = Hashtable.Synchronized(new Hashtable());


#region 构造sqlCommand
/// <summary>
/// 构造sqlCommand
/// </summary>
/// <param name="sqlCommand">System.Data.SqlClient.SqlCommand</param>
/// <param name="commandText">SQL语句</param>
/// <param name="sqlConnection">数据库连接字符串</param>
/// <param name="commandType">SQL语句的属性,默认值为CommandType.Text</param>
/// <param name="sqlTransaction">要在 SQL Server 数据库中处理的 Transact-SQL 事务</param>
/// <param name="sqlParameter">SQL语句参数</param>
private static void PrepareCommand(SqlCommand sqlCommand, string commandText, SqlConnection sqlConnection, CommandType commandType, SqlTransaction sqlTransaction, SqlParameter[] sqlParameter)
{
if (sqlConnection.State != ConnectionState.Open)
{
sqlConnection.Open();
}
sqlCommand.Connection = sqlConnection;
sqlCommand.CommandText = commandText;
if (sqlTransaction != null)
{
sqlCommand.Transaction = sqlTransaction;
}
sqlCommand.CommandType = commandType;
if (sqlParameter != null)
{
foreach (SqlParameter iParm in sqlParam

第1页

你可能喜欢

热门文档

相关文档

  • 常用SqlHelper类

    常用的 SqlHelper 类 using using using using using using System; System.Collections.Generic; System.Text; System.Data; System.Data.SqlClient; System.Collecti...

  • SQLHelper类

    //微软SQLHelper.cs类 中文版 using System; using System.Data; using System.Xml; using System.Data.SqlClient; using System.Collections; using System....

  • 自己写的SqlHelper类

    自己写的SqlHelper类_计算机软件及应用_IT/计算机_专业资料。方法重载,支持参数化语句using System; using System.Collections.Generic; using System.Linq; using Sys...

  • 微软SqlHelper类(中文版)中的方法及说明整理,帮助新手...

    微软SqlHelper类(中文版)中的方法及说明整理,帮助新手认识这个类文件 (后附SqlHelper类(中文版))_计算机软件及应用_IT/计算机_专业资料。微软SqlHelper类(中文版)...

  • SqlHelper类

    SqlHelper类_计算机软件及应用_IT/计算机_专业资料。C# SqlHelper类using System; using System.Collections.Generic; using System.Linq; using System.Text; using...

  • 中文解释的SqlHelper.cs类

    中文解释的SqlHelper.cs类_计算机软件及应用_IT/计算机_专业资料。中文解释的 SqlHelper.cs 类 //这是在网上找的中文解释的 SqlHelper using System; using System...

  • c#中sqlhelper类建立

    c#中sqlhelper类建立_IT/计算机_专业资料。c#中sqlhelper类建立using System; using System.Collections.Generic; using System.Text; using System.Data; using Syst...

  • SqlHelper 类实现详细信息

    SqlHelper 类实现详细信息_IT/计算机_专业资料。SqlHelper 类实现详细信息 SqlHelper 类实现详细信息SqlHelper 类实现详细信息 SqlHelper 类用于通过一组静态方法来封装数...

  • sqlhelper使用指南

    sqlhelper使用指南_IT/计算机_专业资料。sqlhelper使用指南摘要: 摘要:data access application block 是一个 .net 组件,包含优化的数据访问代码,可 以帮助用户调用存...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email