Question Problem with Datareader NextResult Method

franklin83

New member
Joined
Dec 5, 2008
Messages
2
Programming Experience
1-3
Hi, i'm new in the forum, and I searched for threads to solve my problem, but cant find something useful.

My problem is that when I'm reading the results of batch Transact-SQL statements with the nextResult() method the next while to read the second result dont work, it has no records. Thanks for the help. And sorry for my english. :p

VB.NET:
While dr.Read
   strName = dr("ContactID") & ", " & dr("FullName") '& ", " & dr("Phone")
   ListBox1.Items.Add(strName)
End While

[B][COLOR="Blue"]dr.NextResult()[/COLOR][/B] [COLOR="YellowGreen"]'This is true[/COLOR]

[B][COLOR="Red"]While dr.Read[/COLOR][/B] [COLOR="YellowGreen"]'But this is false[/COLOR]
   strName = dr("ContactID") & ", " & dr("FullName") '& ", " & dr("Email")
   CheckedListBox1.Items.Add(strName)
End While
 

franklin83

New member
Joined
Dec 5, 2008
Messages
2
Programming Experience
1-3
is a stored procedure with two selects like this:

select firstname, lastname from customers
select firstname, lastname from employees

and nothing else important
 

MattP

Well-known member
Joined
Feb 29, 2008
Messages
1,206
Location
WY, USA
Programming Experience
5-10
Reader returning false would indicate there are no more results to read suggesting that your second query returned 0 results.
 
Top Bottom