為什么要封裝通用類?
? ? ? ? 數(shù)據(jù)交互:增上改查? ? ? ?
????????相同的事情:連接? ? ? ?
????????T-SQL命令,Command? ? ? ?
????????執(zhí)行命令,選擇執(zhí)行方式
? ? ? ? 得到相應(yīng)結(jié)果
? ? ? ? 關(guān)閉連接
將一些從重復(fù)的邏輯進行封裝,達(dá)到通用的目的
提高復(fù)用率,提高效果,不在考慮交互過程,邏輯清晰
DbHelper類內(nèi)容規(guī)劃:
? ? ? ? 1、連接鑰匙——連接字符串——配置文件
? ? ? ? ? ? ? ? 建立連接——連接釋放——using()
配置數(shù)據(jù)庫連接的字符串
? ? ? ? 2、SqlCommand三種執(zhí)行方法:
? ? ? ? ? ? ? ? 增刪改? ? ? ?ExecuteNonQuery()
? ? ? ? ? ? ? ? 查詢,返回一個值? ? ? ? ExecuteScalar()
? ? ? ? ? ? ? ? 數(shù)據(jù)量小,快速讀取? ? ? ? ExecuteReader()? ? ? ? 生成一個數(shù)據(jù)流SqlDataReader
SqlDataAdapter介紹與創(chuàng)建?
Ado.Net 執(zhí)行T-SQL命令(增刪改查)
? ? ? ? 3、SqlDataAdapter填充Ds、Dt
????????????????查詢出來的結(jié)果是多個結(jié)果集需要進行返回;
使用SqlDataAdapter填充數(shù)據(jù)?
? ? ? ??4、批量增刪改查SqlTransaction
? ? ? ? 傳參? ? ? ? CommandInfo:T-Sql? ? ? ? ?參數(shù)數(shù)組? ? ? ? CommandType文章來源:http://www.zghlxwxcb.cn/news/detail-785411.html
????????文章來源地址http://www.zghlxwxcb.cn/news/detail-785411.html
到了這里,關(guān)于封裝數(shù)據(jù)訪問通用類DbHelper的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!