473,408 Members | 1,866 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,408 software developers and data experts.

using statement with comma

The below seems to work...
using(dbconn=DatabaseHelper.CreateConnection("Davi d_Projects"))
{
using(dbcmd=GetSQLSearchCommand(dbconn))
{
// code here
}
}
However, this version doesn't. Any ideas?
using((dbconn=DatabaseHelper.CreateConnection("Dav id_Projects")),(dbcmd=GetS
QLSearchCommand(dbconn)))
{
// code here
}

Visual Studio .NET underlines the , in red and complains "Invalid expression
term ','".
Nov 16 '05 #1
4 1712
Why should this work?

It is the same as

while(statement)
{
while(statement)
{
}
}

compared to

while((statement), (statement))
{
}
On Fri, 11 Mar 2005 10:18:53 -0000, David Parker <dp@kewly.com> wrote:
The below seems to work...
using(dbconn=DatabaseHelper.CreateConnection("Davi d_Projects"))
{
using(dbcmd=GetSQLSearchCommand(dbconn))
{
// code here
}
}
However, this version doesn't. Any ideas?
using((dbconn=DatabaseHelper.CreateConnection("Dav id_Projects")),(dbcmd=GetS
QLSearchCommand(dbconn)))
{
// code here
}

Visual Studio .NET underlines the , in red and complains "Invalid
expression
term ','".


--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2
In the documentation there is the following example of the using
statement...
using (Font MyFont = new Font("Arial", 10.0f), MyFont2 = new Font("Arial",
10.0f))

I'm guessing the problem is because I'm trying to use two different types
(SqlConnection and SqlCommand) instead of just one (as in the Font example).
Nov 16 '05 #3
Ah, in that case it would be more like

for(int i = 0, j = 1;;)

Only one type declaration is allowed, i and j must be of the same type.

--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #4
From the C# specification:

When a resource-acquisition takes the form of a local-variable-declaration,
it is possible to acquire multiple resources of a given type.
So you are correct; the type of the resources being acquired in the using
statement must be the same.HTHDalePresMCAD, MCDBA, MCSE"David Parker"
<dp@kewly.com> wrote in message news:eR*************@TK2MSFTNGP10.phx.gbl...
In the documentation there is the following example of the using
statement...
using (Font MyFont = new Font("Arial", 10.0f), MyFont2 = new Font("Arial",
10.0f))

I'm guessing the problem is because I'm trying to use two different types
(SqlConnection and SqlCommand) instead of just one (as in the Font
example).

Nov 16 '05 #5

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

Similar topics

15
by: sara | last post by:
Hi I'm pretty new to Access here (using Access 2000), and appreciate the help and instruction. I gave myself 2.5 hours to research online and help and try to get this one, and I am not getting...
15
by: Ben | last post by:
Hey, Not sure if this is the right group to post this on, so sorry in advance if it isn't. I'm using the VS.NET 2005 beta, and am trying to fill one grid, based on what is selected in the...
3
by: James D. Marshall | last post by:
The issue at hand, I believe is my comprehension of using regular expression, specially to assist in replacing the expression with other text. using regular expression (\s*) my understanding is...
9
by: TY | last post by:
Hi all, I have this little simple script: for i in range(10): for j in range(5000000): pass # Timing-delay loop print i When you run it, it behaves as you would expect -- it prints 0...
6
by: FayeC | last post by:
I really need help figuring this out. i have a db with mostly text fields but 2. The user_id field is an autonumber (key) and the user_newsletter is a number (1 and 0) field meaning 1 yes the ...
94
by: krypto.wizard | last post by:
Last month I appeared for an interview with EA sports and they asked me this question. How would you divide a number by 7 without using division operator ? I did by doing a subtraction and...
9
by: Nathan Sokalski | last post by:
I am trying to use the System.Array.ForEach method in VB.NET. The action that I want to perform on each of the Array values is: Private Function AddQuotes(ByVal value As String) As String Return...
4
by: eeb4u | last post by:
I am connecting to MS SQL 2000 from Red Hat EL4 using freetds and currently running queries to get counts on tables etc. When running SELECT queries I notice that the data returns and I have to...
9
by: magix | last post by:
If I have <form action="process.asp" method="get" name="form1"> .... .... <input TYPE=checkbox name=sports VALUE=Cricket> <input TYPE=checkbox name=sports VALUE=Swimming> <input...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.