本文整理汇总了C#中System.Db.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# Db.Connect方法的具体用法?C# Db.Connect怎么用?C# Db.Connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Db
的用法示例。
在下文中一共展示了Db.Connect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}