Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / November 2007

Tip: Looking for answers? Try searching our database.

What is using?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paulo - 07 Nov 2007 18:24 GMT
using (OleDbConnection connection = new
OleDbConnection(ConfigurationManager.ConnectionStrings["Access"].ConnectionString))
{
  using (OleDbCommand command = new OleDbCommand(strSQL, connection))
  {
       command.CommandType = CommandType.Text;
       command.Parameters.Add(new OleDbParameter("@AlbumID", albumid));
       command.Parameters.Add(new OleDbParameter("@Size", (int)size));
      ...
   }
}

What is diference? Any performance improvement? I found the code above on a
starter kit

OleDbConnection connection = new
OleDbConnection(ConfigurationManager.ConnectionStrings["Access"].ConnectionString)
OleDbCommand command = new OleDbCommand(strSQL, connection)
command.CommandType = CommandType.Text;
command.Parameters.Add(new OleDbParameter("@AlbumID", albumid));
command.Parameters.Add(new OleDbParameter("@Size", (int)size));
...

VS 2005 asp.net 2.0 C#

Thanks!
Mark Fitzpatrick - 07 Nov 2007 18:37 GMT
Using in this context allows for automatic displosal and garbage collection
of the objects.

Signature

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression

> using (OleDbConnection connection = new
> OleDbConnection(ConfigurationManager.ConnectionStrings["Access"].ConnectionString))
[quoted text clipped - 22 lines]
>
> Thanks!
George Ter-Saakov - 07 Nov 2007 18:39 GMT
http://davidhayden.com/blog/dave/archive/2005/01/13/773.aspx

George

> using (OleDbConnection connection = new
> OleDbConnection(ConfigurationManager.ConnectionStrings["Access"].ConnectionString))
[quoted text clipped - 22 lines]
>
> Thanks!
IfThenElse - 07 Nov 2007 19:05 GMT
Very good.

> http://davidhayden.com/blog/dave/archive/2005/01/13/773.aspx
>
[quoted text clipped - 26 lines]
>>
>> Thanks!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.