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


C# DbConnection.Close方法代码示例

本文整理汇总了C#中DbConnection.Close方法的典型用法代码示例。如果您正苦于以下问题:C# DbConnection.Close方法的具体用法?C# DbConnection.Close怎么用?C# DbConnection.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DbConnection的用法示例。


在下文中一共展示了DbConnection.Close方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BindGrid

        private void BindGrid(DbConnection conn)
        {
            conn.Open();
                _schema = new DataSet();
                var schema = conn.GetSchema();

                foreach (DataRow dataRow in schema.Rows)
                {
                    var tableName = dataRow["CollectionName"].ToString();
                    if(!_schema.Tables.Contains(tableName))
                    {
                        var dt = conn.GetSchema(tableName);
                        dt.TableName = tableName;
                        _schema.Tables.Add(dt);
                    }
                }
                conn.Close();
                dgSchema.DataSource = _schema.Tables[0];

                cbTable.DataSource = _schema.Tables[0];
                cbTable.DisplayMember = "CollectionName";
                cbTable.ValueMember = "CollectionName";
                _previousWidth = dgSchema.Width;
                _previousState = WindowState;
        }
开发者ID:jschementi,项目名称:ironruby-dbi,代码行数:25,代码来源:Form1.cs

示例2: CloseConnection

        /// <summary>
        /// 关闭一个数据库连接
        /// </summary>
        /// <param name="dbConn">数据库连接对象</param>
        public static void CloseConnection(DbConnection dbConn)
        {
            if (dbConn == null || dbConn.State != ConnectionState.Open)
            {
                return;
            }

            dbConn.Close();
            dbConn.Dispose();
            dbConn = null;
        }
开发者ID:pmsun-bruce,项目名称:DBTool,代码行数:15,代码来源:MysqlHelper.cs

示例3: GetFingerprintList

        private List<Image> GetFingerprintList(Guid guid)
        {
            List<Image> resultlist = new List<Image>();
            string query = "select fprint from fprinttbl where userid=\"" + guid + "\";";
            DbConnection verynewconnect = new DbConnection();
            verynewconnect.Connect();
            MySqlDataReader reader = verynewconnect.SendQuery(query);

            while (reader.Read())
            {
                byte[] barr = (byte[]) reader.GetValue(0);
                resultlist.Add(DeserializeImage(barr));
            }
            reader.Close();
            verynewconnect.Close();
            return resultlist;

        }
开发者ID:kapt-sino,项目名称:fingergraph,代码行数:18,代码来源:FingerDatabase.cs

示例4: Close

 public static void Close(DbConnection conn)
 {
     conn.Close();
     conn.Dispose();
 }
开发者ID:mateuscezar,项目名称:netgore,代码行数:5,代码来源:TestDb.cs

示例5: closeDatabaseConnection

		private void closeDatabaseConnection( DbConnection connection )
		{
			connection.Close ();
		}
开发者ID:jorisrietveld,项目名称:SmsApp,代码行数:4,代码来源:MysqlDaoFactory.cs

示例6: CloseDBConnection

 private static void CloseDBConnection(DbConnection conn)
 {
     try
     {
         if (conn == null)
             return;
         if (conn.State != ConnectionState.Closed)
         {
             conn.Close();
         }
     }
     catch (Exception ex)
     {
         Loggers.LogInfo("CloseDBConnection:" + ex.ToString());
     }
 }
开发者ID:hhahh2011,项目名称:CH.Gps,代码行数:16,代码来源:GpsDataHelper.cs

示例7: GetDbProviderManifestToken

 protected override string GetDbProviderManifestToken(DbConnection connection)
 {
     // we need the connection option to determine what version of the server
     // we are connected to
     bool shouldClose = false;
     if (connection.State == ConnectionState.Closed)
     {
         connection.Open();
         shouldClose = true;
     }
     string version = connection.ServerVersion;
     if (shouldClose)
         connection.Close();
     if (version.StartsWith("6")) return "6.0";
     if (version.StartsWith("5.0")) return "5.0";
     if (version.StartsWith("5")) return "5.1";
     throw new NotSupportedException("Versions of MySQL prior to 5.0 are not currently supported");
 }
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:18,代码来源:ProviderServices.cs

示例8: GetDbProviderManifestToken

        protected override string GetDbProviderManifestToken(DbConnection connection)
        {
            // we need the connection option to determine what version of the server
            // we are connected to
            bool shouldClose = false;
            if (connection.State == ConnectionState.Closed)
            {
                connection.Open();
                shouldClose = true;
            }
            double version = double.Parse(connection.ServerVersion.Substring(0, 3));
            
            if (shouldClose)
                connection.Close();

            if (version < 5.0) throw new NotSupportedException("Versions of MySQL prior to 5.0 are not currently supported");
            if (version < 5.1) return "5.0";
            if (version < 5.5) return "5.1";
            return "5.5";            
        }
开发者ID:LittlePeng,项目名称:ncuhome,代码行数:20,代码来源:ProviderServices.cs

示例9: TableExists

 /// <summary>
 /// This checks if a table exists in a database. 
 /// 
 /// Creds to baavgai and Nakor on this very sly extension method
 /// </summary>
 /// <param name="conn"></param>
 /// <param name="tableName"></param>
 /// <param name="owner"></param>
 /// <param name="database"></param>
 /// <returns></returns>
 public static bool TableExists(DbConnection conn, string tableName, string owner, string database)
 {
     DataTable dt;
     try
     {
         conn.Open();
         dt = conn.GetSchema("Tables", new string[] { database, owner, tableName });
     }
     finally
     {
         conn.Close();
     }
     return (dt == null) ? false : dt.Rows.Count > 0;
 }
开发者ID:TheNotary,项目名称:Extensions_Data,代码行数:24,代码来源:DataExtensions.cs

示例10: ReleaseConnection

 private void ReleaseConnection(DbConnection conn)
 {
     if (conn == null) {
         return;
     }
     if (Transaction.Current == null) {
         conn.Close();
     }
 }
开发者ID:ChristophWurst,项目名称:UFO,代码行数:9,代码来源:Database.cs


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