Hi I keep hitting this error when my sql statement doesn't return any data ...
I'm dumping the rows from the sql statement into a datareader. Here is the code that is generating the error:
The datareader is coming back null and when it hits .HasRows it gives this error. How do I check for a null datareader first? I've tried the following with no success:
still barks on that ... Please advise.
Many Thanks,
- VB Rookie
Code:
Object variable or With block variable not set.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object variable or With block variable not set.
I'm dumping the rows from the sql statement into a datareader. Here is the code that is generating the error:
Code:
If dtRdr.HasRows Then
The datareader is coming back null and when it hits .HasRows it gives this error. How do I check for a null datareader first? I've tried the following with no success:
Code:
If Not (dtRdr Is DBNull.Value) Then
still barks on that ... Please advise.
Many Thanks,
- VB Rookie