|
-
Jan 26th, 2011, 02:52 PM
#4
Thread Starter
PowerPoster
Re: Variable is used before it has been assigned a value. a null reference exception
 Originally Posted by si_the_geek
There are three objects on this line (88 in your last post), and it could be referring to any of them:
..however, the lines just before it assign values to GetInformationDA and GetInformationDS, and as they are not in an If block etc they must run - so it can't be either of those variables.
TableName is given a value earlier on, but only within an If block - and it is entirely possible that none of your conditions will match, so the variable will not be given a value.
To correct that, either add an Else clause with no conditions to give it a default value, or (shorter) set a default value in the declaration.
The ColumnName variable has exactly the same issue.
I was working through the code and I saw what you mean. I put the code within the IF block and I got no complaints. I am going to test to see if it works the way it's supposed to. Thanks si.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|