I have this statement:
if (sqlClass.Reader != null && sqlClass.Reader.HasRows)
{
do
{
data = sqlClass.Reader.GetString(0); //error line System.InvalidOperationException {"Invalid attempt to read when no data is present."}
} while (sqlClass.Reader.Read());
}
the object sqlClass.Reader
is of type System.Data.SqlClient.SqlDataReader
In C# it gives me an InvalidOperationException
but in VB it worked fine, what would the reason be and how do I solve this?
Something like this:
if (null != sqlClass.Reader)
{
while (sqlClass.Reader.Read())
{
data = sqlClass.Reader.GetString(0);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.