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!