asp.net database access component supports using

Source: Internet
Author: User

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;
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.