本文整理汇总了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;
}
示例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;
}
示例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;
}
示例4: Close
public static void Close(DbConnection conn)
{
conn.Close();
conn.Dispose();
}
示例5: closeDatabaseConnection
private void closeDatabaseConnection( DbConnection connection )
{
connection.Close ();
}
示例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());
}
}
示例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");
}
示例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";
}
示例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;
}
示例10: ReleaseConnection
private void ReleaseConnection(DbConnection conn)
{
if (conn == null) {
return;
}
if (Transaction.Current == null) {
conn.Close();
}
}