本文整理汇总了C#中System.Db.Close方法的典型用法代码示例。如果您正苦于以下问题:C# Db.Close方法的具体用法?C# Db.Close怎么用?C# Db.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Db
的用法示例。
在下文中一共展示了Db.Close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: startDataReader
private void startDataReader()
{
Db.DriverEnum dbDriver=databaseDriver();
Db db=new Db(dbDriver);
string qryReader, qryRowCount, fileName, fileBaseName, filePath, fileNameWithPath;
OdbcCommand cmd = new OdbcCommand();
int rowCount, colCount;
OdbcDataReader reader;
rowCount=colCount=0;
qryReader=qryRowCount=fileName=fileBaseName=filePath=fileNameWithPath="";
fileNameWithPath = this.openFileDialog.FileName;
fileName = Fcn.FileName(fileNameWithPath);
fileBaseName = Fcn.FileBaseName(fileName);
filePath = Fcn.FilePath(fileNameWithPath);
switch (dbDriver)
{
case Db.DriverEnum.DBase:
db.Connect("MaxBufferSize=2048;DSN=dBASE Files;PageTimeout=5;DefaultDir=" + filePath +
";DBQ=" + filePath + ";DriverId=533");
qryRowCount="Select count(*) from " + fileBaseName;
qryReader="Select * from " + fileBaseName;
break;
case Db.DriverEnum.CSV:
db.Connect("MaxBufferSize=2048;FIL=text;DSN=CSV;PageTimeout=5;DefaultDir=" + filePath +
";DBQ=" + filePath + ";DriverId=27");
qryRowCount="Select count(*) from " + fileName;
qryReader="Select * from " + fileName;
break;
case Db.DriverEnum.Excel:
db.Connect("MaxBufferSize=2048;DSN=Excel Files;PageTimeout=5;DefaultDir=" + filePath +
";DBQ=" + fileNameWithPath + ";DriverId=790");
qryRowCount="Select count(*) from [Sheet1$]";
qryReader="Select * from [Sheet1$]";
break;
}
cmd = new OdbcCommand(qryRowCount, db.Con);
Def= (int) cmd.ExecuteScalar();
cmd = new OdbcCommand(qryReader, db.Con);
reader = cmd.ExecuteReader();
colCount = reader.FieldCount;
FillPhysicalTable(reader, colCount, rowCount);
db.Close();
}
示例2: Each_Db_Have_Own_Connection
public void Each_Db_Have_Own_Connection()
{
var db = new Db();
var db2 = new Db();
db.Initialize(TestConstants.SqlClientConnectionString, "System.Data.SqlClient", ConnectionStrategyType.Manual);
db2.Initialize(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\romag\Documents\Visual Studio 2015\Projects\EasyDb\EasyDbTests\NorthWind.mdb", "System.Data.OleDb");
db.Open();
Assert.AreEqual(db.Connection.ConnectionString, TestConstants.SqlClientConnectionString);
Assert.AreEqual(db.Connection.Provider, "System.Data.SqlClient");
Assert.AreEqual(db.Connection.ConnectionStrategy, ConnectionStrategyType.Manual);
Assert.AreEqual(db.Connection.State, System.Data.ConnectionState.Open);
Assert.AreEqual(db2.Connection.ConnectionString, @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\romag\Documents\Visual Studio 2015\Projects\EasyDb\EasyDbTests\NorthWind.mdb");
Assert.AreEqual(db2.Connection.Provider, "System.Data.OleDb");
Assert.AreEqual(db2.Connection.ConnectionStrategy, ConnectionStrategyType.Automatic);
Assert.AreEqual(db2.Connection.State, System.Data.ConnectionState.Closed);
db.Close();
}