-
大小: 80KB文件類型: .cs金幣: 1下載: 0 次發布日期: 2021-06-05
- 語言: C#
- 標簽: 微軟??C#??OleDbHelper??源碼??
資源簡介
微軟C# OleDbHelper.cs 源碼,微軟C# OleDbHelper.cs 源碼,微軟C# OleDbHelper.cs 源碼,微軟C# OleDbHelper.cs 源碼
代碼片段和文件信息
//===============================================================================
//?OleDbHelper?based?on?Microsoft?Data?Access?Application?Block?(DAAB)?for?.NET
//?http://msdn.microsoft.com/library/en-us/dnbda/html/daab-rm.asp
//
//?OleDbHelper.cs
//
//?This?file?contains?the?implementations?of?the?OleDbHelper?and?OleDbHelperParameterCache
//?classes.
//
//?The?DAAB?for?MS?Ole?Db?access?for?Oracle?has?been?tested?in?the?context?of?this?Nile?implementation
//?but?has?not?undergone?the?generic?functional?testing?that?the?SQL?version?has?gone?through.
//?You?can?use?it?in?other?.NET?applications?using?Oracle?databases.??For?complete?docs?explaining?how?to?use
//?and?how?it‘s?built?go?to?the?originl?appblock?link.?
//?For?this?sample?the?code?resides?in?the?Nile?namespaces?not?the?Microsoft.ApplicationBlocks?namespace
//==============================================================================
using?System;
using?System.Data;
using?System.xml;
using?System.Data.OleDb;
using?System.Collections;
using?System.Windows.Forms;
namespace?Microsoft.ApplicationBlocks.Data
{
///?
///?The?OleDbHelper?class?is?intended?to?encapsulate?high?performance?scalable?best?practices?for?
///?common?uses?of?OleDbClient.
///?
public?sealed?class?OleDbHelper
{
#region?private?utility?methods?&?constructors
//Since?this?class?provides?only?static?methods?make?the?default?constructor?private?to?prevent?
//instances?from?being?created?with?“new?OleDbHelper()“.
private?OleDbHelper()?{}
///?
///?This?method?is?used?to?attach?array‘s?of?OleDbParameters?to?an?OleDbCommand.
///?
///?This?method?will?assign?a?value?of?DbNull?to?any?parameter?with?a?direction?of
///?InputOutput?and?a?value?of?null.??
///?
///?This?behavior?will?prevent?default?values?from?being?used?but
///?this?will?be?the?less?common?case?than?an?intended?pure?output?parameter?(derived?as?InputOutput)
///?where?the?user?provided?no?input?value.
///?
///?The?command?to?which?the?parameters?will?be?added
///?an?array?of?OleDbParameters?tho?be?added?to?command
private?static?void?AttachParameters(OleDbCommand?command?OleDbParameter[]?commandParameters)
{
foreach?(OleDbParameter?p?in?commandParameters)
{
//check?for?derived?output?value?with?no?value?assigned
if?((p.Direction?==?ParameterDirection.InputOutput)?&&?(p.Value?==?null))
{
p.Value?=?DBNull.Value;
}
command.Parameters.Add(p);
}
}
///?
///?This?method?assigns?an?array?of?values?to?an?array?of?OleDbParameters.
///?
///?array?of?OleDbParameters?to?be?assigned?values
///?array?of?objects?holding?the?values?to?be?assigned
private?static?void?AssignParameterValues(OleDbParameter[]?comma
評論
共有 條評論