当前位置: 首页>>代码示例>>C#>>正文


C# Db.Close方法代码示例

本文整理汇总了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();
        }
开发者ID:evandrojr,项目名称:TreeWorks,代码行数:45,代码来源:OLD_FrmFillDataSet.cs

示例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();
        }
开发者ID:romagny13,项目名称:EasyDb,代码行数:22,代码来源:ReadWriteTests.cs


注:本文中的System.Db.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。