datareaders initialization

janilane

Active member
Joined
Jan 23, 2008
Messages
30
Programming Experience
Beginner
hi, can anybody tell me how to initialize datareaders so i can avoid warnings such as "Variable 'mydatareader' is used before it has been assigned a value. A null reference exception could result at runtime."

thanks:confused:
 
you can assign it a nothingness, just to be explicit with the compiler:
VB.NET:
dim mydatareader as sqldatareader = nothing
In most cases you would assign it directly:
VB.NET:
dim mydatareader as sqldatareader = somesqlcommand.executereader
 
Back
Top