Click here to Skip to main content
15,912,205 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionDelete folder containing files and sub-folder. Pin
Gagan.2028-May-09 23:35
Gagan.2028-May-09 23:35 
AnswerRe: Delete folder containing files and sub-folder. Pin
AhsanS29-May-09 0:12
AhsanS29-May-09 0:12 
AnswerRe: Delete folder containing files and sub-folder. Pin
0x3c029-May-09 0:31
0x3c029-May-09 0:31 
AnswerRe: Delete folder containing files and sub-folder. Pin
Jon_Boy29-May-09 1:58
Jon_Boy29-May-09 1:58 
QuestionVB.Net Compiler Warning.......'used before assigned a value. null exception could result'. Pin
DaveAuld28-May-09 22:58
professionalDaveAuld28-May-09 22:58 
AnswerRe: VB.Net Compiler Warning.......'used before assigned a value. null exception could result'. Pin
DidiKunz28-May-09 23:03
DidiKunz28-May-09 23:03 
GeneralRe: VB.Net Compiler Warning.......'used before assigned a value. null exception could result'. Pin
DaveAuld28-May-09 23:19
professionalDaveAuld28-May-09 23:19 
AnswerRe: VB.Net Compiler Warning.......'used before assigned a value. null exception could result'. [modified] Pin
Luc Pattyn29-May-09 1:30
sitebuilderLuc Pattyn29-May-09 1:30 
Hi Dave,

the problem is the try block may be interrupted by an exception, so the compiler isn't sure the <code>dbReader = dbCMD.ExecuteReader()</code> will be executed, in which case <code>dbReader.Close()</code> uses dbReader which never obtained a value.

The solution to this is:
1. declare dbReader outside of the try block (you have that)
2. AND set it to Nothing
3. apply "test-before-use" outside the try block: If dbReader <> Nothing Then dbReader.Close()

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.

modified on Friday, May 29, 2009 7:53 AM

GeneralRe: VB.Net Compiler Warning.......'used before assigned a value. null exception could result'. Pin
DaveAuld29-May-09 2:03
professionalDaveAuld29-May-09 2:03 
GeneralRe: VB.Net Compiler Warning.......'used before assigned a value. null exception could result'. Pin
Luc Pattyn29-May-09 2:05
sitebuilderLuc Pattyn29-May-09 2:05 
AnswerRe: VB.Net Compiler Warning.......'used before assigned a value. null exception could result'. Pin
chilinhhacker14-Jul-09 16:03
chilinhhacker14-Jul-09 16:03 
QuestionVB6 application using BeforeNavigate2 to capture a filled web page no longer catching pop-ups Pin
hubdawgs28-May-09 17:00
hubdawgs28-May-09 17:00 
AnswerRe: VB6 application using BeforeNavigate2 to capture a filled web page no longer catching pop-ups Pin
Christian Graus28-May-09 21:18
protectorChristian Graus28-May-09 21:18 
GeneralRe: VB6 application using BeforeNavigate2 to capture a filled web page no longer catching pop-ups Pin
hubdawgs29-May-09 4:06
hubdawgs29-May-09 4:06 
QuestionFTP Download problems Pin
CodecCodes28-May-09 15:32
CodecCodes28-May-09 15:32 
AnswerRe: FTP Download problems Pin
Dave Kreskowiak28-May-09 17:33
mveDave Kreskowiak28-May-09 17:33 
Questionworksheetfunction.match Pin
yamanbas28-May-09 8:41
yamanbas28-May-09 8:41 
QuestionGet data off a grid on a web page Pin
MarDude28-May-09 5:54
MarDude28-May-09 5:54 
AnswerRe: Get data off a grid on a web page Pin
Jay Royall28-May-09 6:14
Jay Royall28-May-09 6:14 
GeneralRe: Get data off a grid on a web page Pin
MarDude28-May-09 7:11
MarDude28-May-09 7:11 
GeneralRe: Get data off a grid on a web page Pin
Jay Royall28-May-09 8:22
Jay Royall28-May-09 8:22 
GeneralRe: Get data off a grid on a web page Pin
MarDude28-May-09 13:33
MarDude28-May-09 13:33 
GeneralRe: Get data off a grid on a web page Pin
Jay Royall28-May-09 22:01
Jay Royall28-May-09 22:01 
GeneralRe: Get data off a grid on a web page Pin
MarDude29-May-09 6:48
MarDude29-May-09 6:48 
QuestionHow to Create a Dynamic Page in VB and Print the same. Pin
Kaushal Arora28-May-09 1:55
Kaushal Arora28-May-09 1:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.