Calling code
private void Testusing ()
{
using (idbhelper dbhelper = new SqlHelper (basesysteminfo.usercenterdbconnection))
{
Dbhelper.executenonquery ("Select GETDATE ()");
}
}
Source.
//------------------------------------------------------------
All rights reserved, Copyright (c), Jirisoft, Ltd.
//------------------------------------------------------------
using System;
Using System.Data;
Using System.Data.Common;
Using System.IO;
Using System.Text;
Namespace Dotnet.dbutilities
{
Using Dotnet.utilities;
<summary>
Basedbhelper
A method for connecting to a database tutorial.
///
Change the record
///
2011.01.29 Version: 3.1 Jirigala implements IDisposable interface.
2010.06.13 version: 3.0 Jirigala improved to support static methods, without the database open, close to the way, the autoopenclose switch.
2010.03.14 version: 2.0 Jirigala can not be completely released, concurrency occurs when the exception to solve the problem.
2009.11.25 Version: 1.0 Jirigala improved ConnectionString.
///
Version: 3.1
///
<author>
<name>jirigala</name>
<date>2011.01.29</date>
</author>
</summary>
Public abstract class Basedbhelper:idisposable//Idbhelper
{
Code omitted
public void Dispose ()
{
This.dbcommand = null;
This.dbdataadapter = null;
This.dbtransaction = null;
To close a database connection
if (this.dbconnection!= null)
{
if (this.dbconnection.state!= connectionstate.closed)
{
This.dbconnection.close ();
}
}
This.dbconnection = null;
}
}
}