Last post Aug 17, 2017 12:51 PM by PatriceSc
Aug 17, 2017 12:06 PM|cowasaki|LINK
I am trying to read Sql server data that is a Char(10) field data type. I am unable to read the data using
DataReader.GetString(i). I get error, Invalid attempt to read when no data is present. What data reader method I should use to read this field data?
Aug 17, 2017 12:13 PM|DA924|LINK
Assuming that you are using a While loop for the datareader, then dr.getsting should not be issued outside of the While loop, if there is no data.
Aug 17, 2017 12:51 PM|PatriceSc|LINK
As pointed by
"The default position of the SqlDataReader is before the first record. Therefore, you must call
Read to begin accessing any data."
Make sure Read is called at least once or that you don't try to read data while the previous Read returned false (to tell you don't have any more data to read)...