473,791 Members | 2,899 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Variable does not exist - but does?

Using VS 2005:

Here is a piece of code that is saying that a variable doesn't exist which
obviously does:

public string UpdateTables(Ta bleFieldList tableFields,
UnmappedNamesCo llection unmappedNames, DataView dv)
{
bool newSection = false;
bool parameterExists = false; <---- Here is defined
foreignKeys = new ForeignKeyColle ction();

using (conn = new SqlConnection(C onnectString))
{
try
{
conn.Open();

foreach (TableField tf in tableFields)
{
parameterExists = false; <--------
Error
....

The error is:

The name 'parameterExist s' does not exist in the current context

How can that be?

It is global for the function so how can that error be there?

Is the "using" causing a problem?

Or am I just having a brain fade here?

Thanks,

Tom
Jun 1 '08 #1
3 7107
On Sun, 01 Jun 2008 16:33:37 -0700, tshad <ts***@dslextre me.comwrote:
[...]
The error is:

The name 'parameterExist s' does not exist in the current context

How can that be?
Surely the fraction of code that you posted is not exactly the same as the
code actually suffering the error.

If you can post a concise-but-complete code sample that demonstrates the
error, it's probably possible to point out the problem. Otherwise, I
don't think so.

If I had to guess, I'd guess typo somewhere, either in the declaration or
the use. Much less likely (but still possible) is the possibility that
you're coding in Unicode and managed to get a typographically aliased
character into the variable name. Suffice to say, if the name as used was
actually exactly the same as the name as declared, and the structure of
the code was exactly as you've posted here, you wouldn't be getting the
compiler error.

Pete
Jun 1 '08 #2
I did not find any problem in the given piece of code. However since you are
having a compile-time error, I can reduce the area of investigation by
assuring you that "using" construct does not change the scope or life of a
variable. It is similar to other language structures as foreach or while
loop. Thus if you could paste the complete code, probably we could help you
better.
--
Tariq Abdul Karim

http://tariqkarim.blogspot.com/
"tshad" wrote:
Using VS 2005:

Here is a piece of code that is saying that a variable doesn't exist which
obviously does:

public string UpdateTables(Ta bleFieldList tableFields,
UnmappedNamesCo llection unmappedNames, DataView dv)
{
bool newSection = false;
bool parameterExists = false; <---- Here is defined
foreignKeys = new ForeignKeyColle ction();

using (conn = new SqlConnection(C onnectString))
{
try
{
conn.Open();

foreach (TableField tf in tableFields)
{
parameterExists = false; <--------
Error
....

The error is:

The name 'parameterExist s' does not exist in the current context

How can that be?

It is global for the function so how can that error be there?

Is the "using" causing a problem?

Or am I just having a brain fade here?

Thanks,

Tom
Jun 2 '08 #3
"Tariq Abdul Karim" <Ta************ *@discussions.m icrosoft.comwro te in
message news:2A******** *************** ***********@mic rosoft.com...
>I did not find any problem in the given piece of code. However since you
are
having a compile-time error, I can reduce the area of investigation by
assuring you that "using" construct does not change the scope or life of a
variable. It is similar to other language structures as foreach or while
loop. Thus if you could paste the complete code, probably we could help
you
better.
Well, it is working now and I don't know why.

I did comment it out to get it to build, which it did and when I came back
to copy it to paste in the code here, I uncommented it and it worked fine.

So I don't know what was causing it, but it works now.

Thanks,

Tom
--
Tariq Abdul Karim

http://tariqkarim.blogspot.com/
"tshad" wrote:
>Using VS 2005:

Here is a piece of code that is saying that a variable doesn't exist
which
obviously does:

public string UpdateTables(Ta bleFieldList tableFields,
UnmappedNamesC ollection unmappedNames, DataView dv)
{
bool newSection = false;
bool parameterExists = false; <---- Here is
defined
foreignKeys = new ForeignKeyColle ction();

using (conn = new SqlConnection(C onnectString))
{
try
{
conn.Open();

foreach (TableField tf in tableFields)
{
parameterExists = false; <--------
Error
....

The error is:

The name 'parameterExist s' does not exist in the current context

How can that be?

It is global for the function so how can that error be there?

Is the "using" causing a problem?

Or am I just having a brain fade here?

Thanks,

Tom

Jun 2 '08 #4

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

Similar topics

15
4392
by: | last post by:
Hi, I want to do things this way: I have a bunch of stuff that I want to keep track of while a user is connected to the site. Maybe 50 little peices of information. So I know I can make 50 session variables , or an store an array in a session variable, but what I wanna do is store it all in a class so I can use property get and property let.
134
7917
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that means that if I misspell a variable name, my program will mysteriously fail to work with no error message. If you don't declare variables, you can inadvertently re-use an variable used in an enclosing context when you don't intend to, or
166
8680
by: Graham | last post by:
This has to do with class variables and instances variables. Given the following: <code> class _class: var = 0 #rest of the class
4
14906
by: Gery D. Dorazio | last post by:
Gurus, If a static variable is defined in a class what is the scope of the variable resolved to for it to remain 'static'? For instance, lets say I create a class library assembly that is strongly name which contains the class where the static variable is defined. This library can be referenced by multiple projects. I am fairly sure the static variable does not survive across the application boundry but does it within the application...
6
3123
by: Vmusic | last post by:
Hi, I am using Javascript to add rows to tables, etc. in a function I am calling. I pass the function the ID of the div, and what I want in the rows, and it will add rows to a table in the div. The problem is I need to test for the existence of the table - and if the variable or object doesn't exist already my code errors - PLEASE REMEMBER - I don't know the name of the variable or object I am testing the existance for - it is created...
10
1820
by: ben | last post by:
is there anyway in c to write code that can variably make use of one of two structs (one that has 32 bit vals and the other that has 64 bit vals) throughout the code? i'm writing some code that parses some data. there's a few data types whose max values are 10^10 which requires 34 bits, so a u_int64_t type of variable would be needed to hold them while using/manipulating. (as i write this the more i think about it the more i think what i'm...
1
25702
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause bad breath)? Scope describes the context in which a variable can be used. For example, if a variable's scope is a certain function, then that variable can only be used in that function. If you were to try to access that variable anywhere else in...
3
127
by: tshad | last post by:
Using VS 2005: Here is a piece of code that is saying that a variable doesn't exist which obviously does: public string UpdateTables(TableFieldList tableFields, UnmappedNamesCollection unmappedNames, DataView dv) { bool newSection = false; bool parameterExists = false; <---- Here is defined
3
2997
by: adiel_g | last post by:
Hello everyone, I am trying to move a field name to a variable in vb.net. For example, first I retrieve the record from the database and save its value: .... userGroup = ds.Tables("Default").Rows(x).Item("UserGroupAccess").ToString 'retrive access value from dataset ....
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9515
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10426
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10154
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.