473,734 Members | 2,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to iterate through rows of a query?

Hi,

If I have this sequence:

Dim dbConnection As System.Data.IDb Connection = New
System.Data.Sql Client.SqlConne ction(Configura tionSettings.Ap pSettings("DB") )
Dim dbCommand As System.Data.IDb Command = New
System.Data.Sql Client.SqlComma nd
Dim dataAdapter As System.Data.IDb DataAdapter = New
System.Data.Sql Client.SqlDataA dapter
Dim dataSet As System.Data.Dat aSet = New System.Data.Dat aSet

dbCommand.Conne ction = dbConnection
dbCommand.Comma ndText = "SELECT * FROM MY_TABLE"

dataAdapter.Sel ectCommand = dbCommand

dataAdapter.Fil l(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
Nov 19 '05 #1
2 2083
you mean like this:

for each row as DataRow in dataSet.Tables( 0).Rows
dim id as integer = convert.toInt32 (row("My_TableC olumn1"))
dim name as string = convert.ToStrin g(row("My_Table Column2"))
...
next

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Lacka" <la***@chello.h u> wrote in message
news:u7******** *****@TK2MSFTNG P11.phx.gbl...
Hi,

If I have this sequence:

Dim dbConnection As System.Data.IDb Connection = New
System.Data.Sql Client.SqlConne ction(Configura tionSettings.Ap pSettings("DB") ) Dim dbCommand As System.Data.IDb Command = New
System.Data.Sql Client.SqlComma nd
Dim dataAdapter As System.Data.IDb DataAdapter = New
System.Data.Sql Client.SqlDataA dapter
Dim dataSet As System.Data.Dat aSet = New System.Data.Dat aSet

dbCommand.Conne ction = dbConnection
dbCommand.Comma ndText = "SELECT * FROM MY_TABLE"

dataAdapter.Sel ectCommand = dbCommand

dataAdapter.Fil l(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

Nov 19 '05 #2
Thanks!
Nov 19 '05 #3

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

Similar topics

7
12089
by: Egor Shipovalov | last post by:
I'm implementing paging through search results using cursors. Is there a better way to know total number of rows under a cursor than running a separate COUNT(*) query? I think PostgreSQL is bound to know this number after the first FETCH, isn't it? On a side note, why queries using LIMIT are SO terribly slow, compared to cursors and sometimes even ones without LIMIT? Shouldn't LIMIT be internally implemented using cursor mechanism then?...
4
1415
by: Antonio Budano | last post by:
Hi there, How can I iterate through collections starting not from the first item but from an offset? I need to check if a dataset contains records that have some field values that can conflict with some other records. So my code would be like the following: MyDataSet copyDataSet = new MyDataSet(); copyDataSet = myDataSet.Copy();
2
2183
by: martin | last post by:
hi, I am using vb.net. I have wrote a data access class and one of my methods returns a dataset. I would like to iterate through this, although this is proving problematic for me. Can anybody please point out the addition that I would need to the follwoing code.
7
5266
by: Dan Sikorsky | last post by:
How do you iterate thru a dataset to change money fields to a different value? Here's what I have. My dataset is filled directly from a stored procedure. ' Create Instance of Connection and Command Object Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")) Dim myCommand As New SqlDataAdapter("OrdersList", myConnection)
4
3075
by: dallasfreeman | last post by:
I'm looking at a quick way to get results that are displayed as rows to display as columns. I have three tables:- - The Questions for the survey - The Results of the survey (Columns are listed as question numbers) - The Survey Extra Results (As additional questions can be listed into the Questions table, has 3 columns (a link/id to the survey id, a link/id to the question id, and the answer the user gave).
5
4195
by: ameshkin | last post by:
What I want to do is very simple, but I'm pretty new at PHP and its a little hard for me. I have one page, where there are a rows of checkboxes. A button selects all checkboxes, and then presses delete. When delete is pressed, I want to go to a next page and run a sql command for every single box thats checked. The checkboxes store a value, and multiple boxes can be checked.
17
4582
by: pbd22 | last post by:
Hi. How does one return a range of rows. I know that "Top 5" will return rows 0 - 5 but, how do I get 6 - 10? thanks
1
2369
by: prathna | last post by:
Hi .. I have a logic:iterate tag which will display 5 rows each row with a drop downlist and 2 textfields.now by default all the rows will be shown.how do i hide all the rows except the first one.i know how to show/hide a row when its not dynamic.but i dont know how to do it when its logic iterate tag. <logic:iterate indexId="index" id="phoneItem" name="nameForm" property="results"> <% String dropdownType = "results.dropdownType";...
4
5585
by: Peted | last post by:
Hi I need to iterate through a winforms visible datagrid, in a legacy application, to update it a little bit to change the background colours of the grid. This seems to be more dificult than i expected as it does not appear the DataGridRows collection is exposed with DataGrid. Is there a way to/ or best way to iterate through the rows of a
0
8946
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9449
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9310
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4550
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.