Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to iterate through rows of a query?

Reply
Thread Tools

How to iterate through rows of a query?

 
 
Lacka
Guest
Posts: n/a
 
      12-31-2004
Hi,

If I have this sequence:

Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(ConfigurationS ettings.AppSettings("DB"))
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
Dim dataAdapter As System.Data.IDbDataAdapter = New
System.Data.SqlClient.SqlDataAdapter
Dim dataSet As System.Data.DataSet = New System.Data.DataSet

dbCommand.Connection = dbConnection
dbCommand.CommandText = "SELECT * FROM MY_TABLE"

dataAdapter.SelectCommand = dbCommand

dataAdapter.Fill(dataSet)

how can I iterate through the rows of the query, like this

<open result set>
<while not Eof(result set)>
<read in the current row>
<store fields into variables>
<do something with stored values>
<step result set forward ("next")>
<end while>
<close result set>

thanks,
Lacka


 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      12-31-2004
you mean like this:

for each row as DataRow in dataSet.Tables(0).Rows
dim id as integer = convert.toInt32(row("My_TableColumn1"))
dim name as string = convert.ToString(row("My_TableColumn2"))
...
next

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/


"Lacka" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> If I have this sequence:
>
> Dim dbConnection As System.Data.IDbConnection = New
>

System.Data.SqlClient.SqlConnection(ConfigurationS ettings.AppSettings("DB"))
> Dim dbCommand As System.Data.IDbCommand = New
> System.Data.SqlClient.SqlCommand
> Dim dataAdapter As System.Data.IDbDataAdapter = New
> System.Data.SqlClient.SqlDataAdapter
> Dim dataSet As System.Data.DataSet = New System.Data.DataSet
>
> dbCommand.Connection = dbConnection
> dbCommand.CommandText = "SELECT * FROM MY_TABLE"
>
> dataAdapter.SelectCommand = dbCommand
>
> dataAdapter.Fill(dataSet)
>
> how can I iterate through the rows of the query, like this
>
> <open result set>
> <while not Eof(result set)>
> <read in the current row>
> <store fields into variables>
> <do something with stored values>
> <step result set forward ("next")>
> <end while>
> <close result set>
>
> thanks,
> Lacka
>
>



 
Reply With Quote
 
 
 
 
Lacka
Guest
Posts: n/a
 
      12-31-2004
Thanks!


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Iterate through table rows annoyingmouse@gmail.com Javascript 5 06-23-2010 12:57 PM
iterate excel columns/rows Venkat r m Reddi Ruby 0 12-30-2009 09:32 AM
How to iterate 2 nested collections w <logic:iterate> without a"getter" John Java 4 04-01-2008 09:46 AM
nested:iterate or logic: iterate with multibox?? runescience Java 0 02-09-2006 12:57 AM
<logic:iterate /> iterate beyond items in the collection Gogo Java 1 09-04-2003 08:40 PM



Advertisments