Help with the Use of SqlDataReader
Hi There,
What i need to do is retrieve each field from a select query individually into a variable for use later on.
This is my code as it stands so far...
try
do while myReader.Read
val1 = myReader.GetString(1)
val2 = myReader.GetString(2)
val3 = myReader.GetString(3)
loop
catch ex as system.exception
msgbox(ex.message)
end try
myReader.close()
Unfortunately, when it gets to retrieving 2, it throws an exceptionsaying that it is null, and therefore will not go on to retrieve val3. The thing thats really odd about this, is that i know for a fact that 2 is not null at all.
So, what i think i might need to do is create an array of what myReader reads, but i have absolutely no idea how to do this, and how then to access the values within the array.
My select query is " select * from table1 where id = 00001 ".
Your help with this will be much appreciated.
Regards,
Michelle
Hi There,
What i need to do is retrieve each field from a select query individually into a variable for use later on.
This is my code as it stands so far...
try
do while myReader.Read
val1 = myReader.GetString(1)
val2 = myReader.GetString(2)
val3 = myReader.GetString(3)
loop
catch ex as system.exception
msgbox(ex.message)
end try
myReader.close()
Unfortunately, when it gets to retrieving 2, it throws an exceptionsaying that it is null, and therefore will not go on to retrieve val3. The thing thats really odd about this, is that i know for a fact that 2 is not null at all.
So, what i think i might need to do is create an array of what myReader reads, but i have absolutely no idea how to do this, and how then to access the values within the array.
My select query is " select * from table1 where id = 00001 ".
Your help with this will be much appreciated.
Regards,
Michelle