473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

What is using?

using (OleDbConnection connection = new
OleDbConnection(ConfigurationManager.ConnectionStr ings["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.ConnectionStr ings["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!
Nov 7 '07 #1
3 1616
Using in this context allows for automatic displosal and garbage collection
of the objects.
--

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression

"Paulo" <pr*****@uol.com.brwrote in message
news:ef*************@TK2MSFTNGP04.phx.gbl...
using (OleDbConnection connection = new
OleDbConnection(ConfigurationManager.ConnectionStr ings["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.ConnectionStr ings["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!

Nov 7 '07 #2

http://davidhayden.com/blog/dave/arc...01/13/773.aspx

George

"Paulo" <pr*****@uol.com.brwrote in message
news:ef*************@TK2MSFTNGP04.phx.gbl...
using (OleDbConnection connection = new
OleDbConnection(ConfigurationManager.ConnectionStr ings["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.ConnectionStr ings["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!

Nov 7 '07 #3
Very good.
"George Ter-Saakov" <gt****@cardone.comwrote in message
news:O%****************@TK2MSFTNGP03.phx.gbl...
>
http://davidhayden.com/blog/dave/arc...01/13/773.aspx

George

"Paulo" <pr*****@uol.com.brwrote in message
news:ef*************@TK2MSFTNGP04.phx.gbl...
>using (OleDbConnection connection = new
OleDbConnection(ConfigurationManager.ConnectionSt rings["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.ConnectionSt rings["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!


Nov 7 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
12
by: Dario | last post by:
The following simple program behaves differently in Windows and Linux . #include <stdexcept> #include <iostream> #include <string> using namespace std; class LogicError : public logic_error {...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
44
by: lester | last post by:
a pre-beginner's question: what is the pros and cons of .net, compared to ++ I am wondering what can I get if I continue to learn C# after I have learned C --> C++ --> C# ?? I think there...
9
by: John Cho | last post by:
// CHO, JOHN #include<iostream> class fracpri{ int whole; int numer; int denom;
12
by: Steven T. Hatton | last post by:
This is something I've been looking at because it is central to a currently broken part of the KDevelop new application wizard. I'm not complaining about it being broken, It's a CVS images. ...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
9
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
0
by: andy6 via DotNetMonster.com | last post by:
I want to display a webpage. The user selects a value from a drop down. This value is put into a custom header and added to the http pipeline. Then the page is redirected in the EndRequest method...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.