資料訪問通用類(C )

2021-06-02 05:28:53 字數 1006 閱讀 7406

using system;

using system.collections.generic;

using system.linq;

using system.web;

using system.data;

using system.data.sqlclient;

using system.configuration;

namespace sqlhelper

/// /// 執行查詢並將結果返回至datatable中

///

/// 查詢語句

/// 可能帶的引數

/// 返回一張查詢結果表

public static datatable executedatatable(string strsql, params sqlparameter parameters)

dataset ds = new dataset();

using (sqldataadapter adapter = new sqldataadapter(cmd))}}

}/// /// 執行對資料的增刪改操作

///

///

///

public static void executenonquery(string strsql, params sqlparameter parameters)

cmd.executenonquery();}}

}/// /// 執行查詢並返回結果集中第一行第一列的值

///

///

///

///

public static object executescalar(string strsql, params sqlparameter parameters)

return cmd.executescalar();}}

}}

}

c 通用資料庫訪問類

在應用程式的設計中,資料庫的訪問是非常重要的,我們通常需要將對資料庫的訪問集中起來,以保證良好的封裝性和可維護性。在.net中,資料庫的訪問,對於微軟自家的sqlserver和其他資料庫 支援oledb 採用不同的訪問方法,這些類分別分布於system.data.sqlclient和system.d...

通用資料訪問

code 在開發過程中資料庫可能用的很多,可能即用sqlserver 又用 oracle 等等.總結了幾次在網上看了很多資料寫了個覺得還可以用的,需要修改的地方很多希望各位大哥指教,小弟在這裡先謝了 namespace connection try catch exception exp final...

c 操作mysql通用類 C 資料庫操作通用類

usingsystem usingsystem.collections.generic usingsystem.linq usingsystem.text usingsystem.data.common usingsystem.data usingsystem.reflection namespac...