資源描述:
《中文的SqlHelper詳解》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、中文的SqlHelper.cs類????//這是在網(wǎng)上找的中文解釋的SqlHelperusing?System;using?System.Configuration;using?System.Data;using?System.Data.SqlClient;using?System.Collections;?namespace?com.DataAccess{?????///?????///?SqlHelper類提供很高的數(shù)據(jù)訪問性能,?????///?使用SqlClient類的通用定義.?
2、???///?????public?abstract?class?SqlHelper????{?????????//定義數(shù)據(jù)庫連接串????????public?static?readonly?string?ConnectionStringLocalTransaction?=?ConfigurationManager.ConnectionStrings["TestConnectionString"].ConnectionString;????????//public?static?rea
3、donly?string?ConnectionStringInventoryDistributedTransaction?=?ConfigurationManager.ConnectionStrings["SQLConnString2"].ConnectionString;????????//public?static?readonly?string?ConnectionStringOrderDistributedTransaction?=?ConfigurationManager.ConnectionSt
4、rings["SQLConnString3"].ConnectionString;????????//public?static?readonly?string?ConnectionStringProfile?=?ConfigurationManager.ConnectionStrings["SQLProfileConnString"].ConnectionString;?????????//?存貯Cache緩存的Hashtable集合????????private?static?Hashtable?par
5、mCache?=?Hashtable.Synchronized(new?Hashtable());?????????///?????????///?使用連接字符串,執(zhí)行一個SqlCommand命令(沒有記錄返回)????????///?使用提供的參數(shù)集.????????///?????????///?????????///?示例:??????????///??int?result?=?ExecuteNonQuery(connString,?Comman
6、dType.StoredProcedure,?"PublishOrders",?new?SqlParameter("@prodid",?24));????????///?????????///?一個有效的SqlConnection連接串????????///?命令類型CommandType(stored?procedure,?text,?etc.)
7、m>????????///?存貯過程名稱或是一個T-SQL語句串????????///?執(zhí)行命令的參數(shù)集????????///?受此命令影響的行數(shù)????????public?static?int?ExecuteNonQuery(string?connectionString,?CommandType?cmdType,?st
8、ring?cmdText,?params?SqlParameter[]?commandParameters)????????{?????????????SqlCommand?cmd?=?new?SqlCommand();?????????????using?(SqlConnection?conn?=?new?SqlConnection(connectionString))????????????{????????