91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

C#的sqlserver數據庫操作封裝類,封裝了sql語句的查詢、修改、插入、刪除操作,以及存儲過程的執行,包括有輸入、輸出參數的存儲過程,存儲過程的執行無需輸入任何參數名稱,只需輸入參數值即可。同時封裝了大批量數據的更新操作,是普通DataAdapter和Command批量操作效率的30倍以上。

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections;
using?System.Collections.Generic;
using?System.Linq;
using?System.Web;
using?System.Data.SqlClient;
using?System.Data;

namespace?SqlHelper
{
????public?class?SqlCompose
????{
????????#region?構造函數
????????///?
????????///?構造函數
????????///?

????????///?
????????public?SqlCompose(string?connStr)
????????{
????????????this.connStr?=?connStr;
????????}
????????#endregion

????????#region?變量
????????//數據庫連接對象
????????private?SqlConnection?_connection?=?null;
????????//數據庫連接字符串
????????private?string?connStr?=?string.Empty;
????????#endregion

????????#region?屬性
????????///?
????????///?數據庫連接對象
????????///?

????????private?SqlConnection?Connnection
????????{
????????????get
????????????{
????????????????if?(this._connection?==?null?||?this._connection.State?==?ConnectionState.Broken?||?this._connection.State?==?ConnectionState.Closed)
????????????????{
????????????????????this._connection?=?new?SqlConnection(connStr);
????????????????}
????????????????return?this._connection;
????????????}????????????
????????}
????????#endregion

????????#region?方法
????????#region?BuildQueryCommand
????????///?
????????///?創建Command對象
????????///?

????????///?sql語句或存儲過程名稱
????????///?是否是存儲過程
????????///?輸入參數集合???
????????///?輸出參數集合?
????????///?
????????private?SqlCommand?BuildQueryCommand(string?sqlOrprocedureName?bool?isProcedure?object[]?inParameters?object[]?outParameters)
????????{
????????????SqlCommand?command?=?new?SqlCommand(sqlOrprocedureName?this.Connnection);
????????????command.CommandType?=?isProcedure???CommandType.StoredProcedure?:?CommandType.Text;

????????????if?(isProcedure?&&?((inParameters?!=?null?&&?inParameters.Length?>?0)?||?(outParameters?!=?null?&&?outParameters.Length?>?0)))
????????????{
????????????????//獲取存儲過程參數,獲取參數順序為,存儲過程執行返回值ReturnValue>輸入參數Input>輸入輸出參數InputOutput>輸出參數Output。
????????????????//其中Output為純輸出參數,不用傳參,但sqlserver存儲過程里定義的輸出參數,在C#中一般為InputOutput類型,除非存儲過程中定義的是返回值而非輸出參數。
????????????????command.Connection.Open();
????????????????SqlCommandBuilder.DeriveParameters(command);
????????????????command.Connection.Close();
????????????????
????????????????try
????????????????{???????????????????
????????????????????//存儲過程參數賦值
????????????????????for?(int?i?=?1;?i?????????????????????{
????????????????????????if?(inParameters?!=?null?&&?inParameters.Length?>?0?&&?i?<=?inParameters.Length)
????????????????????????{
????????????????????????????command.Parameters[i].Value?=?inParameters[i?-?1];
????????????????????????}
????????????????????????else?if?(outParameters?!=?null?&&?outParameters.Length?>?0)
????????????????????????{
???????

評論

共有 條評論