473,479 Members | 2,060 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

sqlreader Do...while problem

drBranchForm = sqldatareader
For Each drBranch In dtUserBranch
Do While drBranchForm.Read
.......... Problem (A)
Loop
Next

I found that the datarreader only loop onces , ?? How can I make it restart
the sqldatareader ???
Thanks
Nov 21 '05 #1
3 1177
Hi,

Here is an working example. Would have to see more of your code to
figure out the problem you are having.

Dim conn As SqlConnection

Dim strConn As String

Dim drCustomer As SqlDataReader

Dim daCustomer As SqlDataAdapter

Dim cmd As SqlCommand

Dim ds As New DataSet

strConn = "Server = " & Environment.MachineName & ";"

strConn &= "Database = NorthWind;"

strConn &= "Integrated Security = SSPI;"

conn = New SqlConnection(strConn)

cmd = New SqlCommand("Select * from Customers", conn)

conn.Open()

drCustomer = cmd.ExecuteReader

Do While drCustomer.Read

Trace.WriteLine(drCustomer.Item("CustomerID").ToSt ring)

Loop

conn.Close()

Ken

-----------------------------------

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
drBranchForm = sqldatareader
For Each drBranch In dtUserBranch
Do While drBranchForm.Read
.......... Problem (A)
Loop
Next

I found that the datarreader only loop onces , ?? How can I make it restart
the sqldatareader ???
Thanks

Nov 21 '05 #2
Do you know if you have many transaction you need to call NextResult ??

again, need to provide us more code please ^_^

From http://www.developmentnow.com/g/38_2...ile-problem.ht

Posted via DevelopmentNow.com Group
http://www.developmentnow.com
Nov 21 '05 #3
However you can just try something like this.
Dim drBranchForm As SqlDataReader
drBranchForm = myCommand.ExecuteReader()
' Always call Read before accessing data.
While drBranchForm.Read()
Console.WriteLine(( drBranchForm.GetInt32(0) & ", " & drBranchForm.GetString(1)))
End While
' always call Close when done reading.
drBranchForm.Close()

take out the FOR EACH loop first.

Hope this can help ^_^
From http://www.developmentnow.com/g/38_2...le-problem.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

147
10000
by: Michael B Allen | last post by:
Should there be any preference between the following logically equivalent statements? while (1) { vs. for ( ;; ) { I suspect the answer is "no" but I'd like to know what the consensus is
7
1420
by: Kris Desmadryl | last post by:
Hi all, I create a new asp project, with just one button on the startup form but when I run I always get a messagebox with the error : "Error while trying to run project." That's all what I see...
0
1532
by: Chris Morse | last post by:
Hi, Following is a function I wrote to export the rows of an arbitrary table. It's not complete yet, in that it currently does not output to a file (it uses Debug.WriteLine() at the moment) and...
1
2181
by: Agnes | last post by:
I got 2 sql statment to check whether the account code exsist in one of their tables. and then want to get the counter. Thanks a lot. -----my vb.net syntax----- cmdSearch.Parameters.Add(New...
5
2544
by: c676228 | last post by:
Hi all, I am stuck with this problem. the code is like this: Dim sqlreader As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection) ...
3
2982
by: Saurabh Prabhu | last post by:
Hi there, I am using a SQL reader to read data from a table. Here is how I use it. SqlDataReader lobj_Table = SqlHelper.ExecuteReader(ConnectionObject,CommandType.Text,lstr_SQL); Now I need...
0
3083
by: adriann | last post by:
I have a strange problem whereby an attempt at a looped SQL query only passes successfully once. I get the error.. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result...
2
2059
by: d3vkit | last post by:
Okay so I can NOT get my while loop to work. It's the most confusing thing I've ever come across. It was working fine and then suddenly, nothing. No error. The page just dies. I am using PHP5 with...
2
3123
by: swethak | last post by:
Hi, I am getting the problem the problem with google map in Internet Explorer. This map worked fine in mozilla . When i opened the same map in Internet Explorer i am getting the error...
0
7033
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7027
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5318
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4763
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4468
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2987
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2974
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
557
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.