資料庫訪問元件,仿企業庫

2022-09-01 14:33:17 字數 3916 閱讀 9853

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.configuration;

namespace blog.data

/// /// 完整提供程式

///

public string providername

/// /// 構造配置物件

///

/// 連線字串

/// 提供程式名稱

/// /// 構造配置物件

///

/// 連線字串名稱

}}//名稱:資料訪問元件using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.data.common;

using system.data;

using system.data.providerbase;

namespace blog.data

#endregion

#region 獲取資料庫連線物件

/// /// 獲取資料庫連線物件

///

/// 資料庫連線物件

public dbconnection getconnection()

#endregion

#region 建立事務

/// /// 建立事務

///

/// 事務物件

public dbtransaction createdbtransaction()

#endregion

#region 建立資料庫命令

/// /// 建立資料庫命令

///

/// 命令文字

/// 命令物件

public dbcommand createdbcommand(string commandtext)

dbcommand command = conn.createcommand();

command.commandtext = commandtext;

command.commandtype = commandtype.text;

command.connection = conn;

return command;

}/// /// 建立資料庫命令

///

/// 命令文字

/// 命令型別

/// 命令物件

public dbcommand createdbcommand(string commandtext, commandtype type)

dbcommand command = conn.createcommand();

command.commandtext = commandtext;

command.commandtype = type;

command.connection = conn;

return command;

}#endregion

/// /// 執行命令

///

/// 命令

/// 值

public idatareader executereader(dbcommand command)

catch (exception ex)

}#region executescalar

/// /// 執行命令

///

/// 命令

/// 值

public object executescalar(dbcommand command)

catch (exception ex)

}/// /// 執行命令

///

/// 命令文字

/// 受影響行數

public object executescalar(string commandtext)

catch (exception ex)

}#endregion

#region executenonquery

/// /// 執行命令

///

/// 命令

/// 受影響行數

public int executenonquery(dbcommand command)

catch (exception ex)

}/// /// 執行命令

///

/// 命令

/// 事務

/// 受影響行數

public int executenonquery(dbcommand command, dbtransaction transaction)

catch (exception ex)

}/// /// 執行命令

///

/// 命令文字

/// 受影響行數

public int executenonquery(string commandtext, dbtransaction transaction)

catch (exception ex)

}/// /// 執行命令

///

/// 命令文字

/// 受影響行數

public int executenonquery(string commandtext)

catch (exception ex)

}#endregion

#region executedataset

/// /// 執行命令

///

/// 命令

/// 值

public dataset executedataset(dbcommand command)

catch (exception ex)

}/// /// 執行命令

///

/// 命令

/// 值

public dataset executedataset(string commandtext)

catch (exception ex)

}/// /// 獲取資料集(分頁)

///

/// 命令

/// 表名

/// 條件

/// 排序

/// 資料頁

/// 頁大小

/// 資料集

public dataset executedataset(dbcommand command, string tablename, string strwhere, string orderby, int page, int pagesize)

catch (exception ex)

}#endregion

#region 引數

/// /// 新增引數

///

/// 命令

/// 引數名

/// 引數型別

/// 引數值

public void addparameter(dbcommand command, string parametername, dbtype type, object value)

/// /// 新增引數

///

/// 命令

/// 引數名

/// 引數型別

/// 引數值

public void addparameter(dbcommand command, string parametername, dbtype type, object value, parameterdirection direction)

#endregion

}}

微軟企業庫 資料訪問

微軟企業庫 資料訪問 第一步 新增程式集引用 需要在專案中新增對下列程式集的引用 microsoft.practices.enterpriselibrary.common.dll microsoft.practices.enterpriselibrary.data.dll microsoft.pra...

微軟企業庫資料訪問

database db null region 一般呼叫 db databasefactory.createdatabase connection string int count int db.executescalar commandtype.text,select count from cms...

企業庫 Enterprise Library 介紹

管.net平台已經提供一套滿足穩健程式開發的功能強大的工具和類庫,但我還是經常被微軟推出的其它額外免費的附加類庫所驚奇。在我看來,最為值得注意就是企業庫 enterprise library 這套由模式與實踐組 patterns and practices group 開發的程式模組應用最為有效的方...