Home All Groups Group Topic Archive Search About
Author
11 Nov 2005 8:23 PM
Pat Brown
Wondering why the following if statement does not run.

// obviously the name of my datareader is not sqldatareader
if(sqldatareader.read())
{
//code
}

For some reason when my code hits the following if statement it is reading
"(!sqldatareader.read()).
There are no other sqldatareaders open.
When querying the storedprocedure in query analyzer records are returned.
The connection is open and everything goes fine while reading the name of
the stored proc, etc.. 
What other reasons might the datareader.read() not be executing?

Author
11 Nov 2005 8:34 PM
Greg Burns
Try checking the sqldatareader's HasRows property...

Show quote
"Pat Brown" <PatBr***@discussions.microsoft.com> wrote in message
news:4AE3F85D-6FD6-4F80-8216-91E2FEB12B12@microsoft.com...
> Wondering why the following if statement does not run.
>
> // obviously the name of my datareader is not sqldatareader
> if(sqldatareader.read())
> {
> //code
> }
>
> For some reason when my code hits the following if statement it is reading
> "(!sqldatareader.read()).
> There are no other sqldatareaders open.
> When querying the storedprocedure in query analyzer records are returned.
> The connection is open and everything goes fine while reading the name of
> the stored proc, etc..
> What other reasons might the datareader.read() not be executing?
>
Author
11 Nov 2005 10:09 PM
Alazel Acheson [MSFT]
You might also need to check for multiple resultsets from your query (i.e.
what does NextResult() return?).

--
~Alazel

Alazel Acheson
Software Developer
Microsoft SQL Server

This posting is provided "AS IS" with no warranties, and confers no rights.

Show quote
"Greg Burns" <bluebunny@newsgroups.nospam> wrote in message
news:eBrCW9v5FHA.3188@TK2MSFTNGP15.phx.gbl...
> Try checking the sqldatareader's HasRows property...
>
> "Pat Brown" <PatBr***@discussions.microsoft.com> wrote in message
> news:4AE3F85D-6FD6-4F80-8216-91E2FEB12B12@microsoft.com...
>> Wondering why the following if statement does not run.
>>
>> // obviously the name of my datareader is not sqldatareader
>> if(sqldatareader.read())
>> {
>> //code
>> }
>>
>> For some reason when my code hits the following if statement it is
>> reading
>> "(!sqldatareader.read()).
>> There are no other sqldatareaders open.
>> When querying the storedprocedure in query analyzer records are returned.
>> The connection is open and everything goes fine while reading the name of
>> the stored proc, etc..
>> What other reasons might the datareader.read() not be executing?
>>
>
>

AddThis Social Bookmark Button