473,382 Members | 1,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Iterating through the records in a dataset

Hi all,

I am new to vb.net and I am trying to use the vb.net components, rather than
relying on the VB6 compatibility stuff with which I am more familiar.

However, I seem to have fallen at the first hurdle. I have created a
dataset linked to a single SQL table and would like to iterate through the
records in it, it, changing one of the fields as I go, but I can't seem to
find a way of doing this. I guess all the records are in a collection of
some sort but I can't seem to access them.

Any help gratefully received.

Thanks

Mark
Sep 6 '06 #1
3 2008

Collection of rows.

For Each row as DataRow in theDataSet.Tables[0].Rows

mark blackall wrote:
Hi all,

I am new to vb.net and I am trying to use the vb.net components, rather than
relying on the VB6 compatibility stuff with which I am more familiar.

However, I seem to have fallen at the first hurdle. I have created a
dataset linked to a single SQL table and would like to iterate through the
records in it, it, changing one of the fields as I go, but I can't seem to
find a way of doing this. I guess all the records are in a collection of
some sort but I can't seem to access them.

Any help gratefully received.

Thanks

Mark
Sep 6 '06 #2

"mark blackall" <bl******@btinternet.comwrote in message
news:ed*******************@news.demon.co.uk...
Hi all,

I am new to vb.net and I am trying to use the vb.net components, rather
than relying on the VB6 compatibility stuff with which I am more familiar.

However, I seem to have fallen at the first hurdle. I have created a
dataset linked to a single SQL table and would like to iterate through the
records in it, it, changing one of the fields as I go, but I can't seem to
find a way of doing this. I guess all the records are in a collection of
some sort but I can't seem to access them.

Any help gratefully received.

Thanks

Mark

I had trouble understanding ADO.Net when I switched from ADODB using VB6 :)

Look at the big differences between the two in order to help understand
them. ADODB contain recordsets that you can update directly and calling a
single Update method on the Recordset will update the database. ADO.Net has
no such method.

A DataSet is NOT a recordset, nor should it be used as one. It helps me to
see a DataSet as an in-memory database. Just like a db, the DataSet
contains tables (stores of data). The DataTable
Sep 6 '06 #3

"mark blackall" <bl******@btinternet.comwrote in message
news:ed*******************@news.demon.co.uk...
Hi all,

I am new to vb.net and I am trying to use the vb.net components, rather
than relying on the VB6 compatibility stuff with which I am more familiar.

However, I seem to have fallen at the first hurdle. I have created a
dataset linked to a single SQL table and would like to iterate through the
records in it, it, changing one of the fields as I go, but I can't seem to
find a way of doing this. I guess all the records are in a collection of
some sort but I can't seem to access them.

Any help gratefully received.

Thanks

Mark

Oops, ignore my previous post...darn shift-enter!!!

What helps me is looking at DataSets as small, in-memory databases. Each
DataSet can contain one or more DataTable instances. Each DataTable contain
DataRows. The rows, when updated, do NOT update the SQL Server (or other
dbms) automatically. Instead, the in-memory db (DataSet/DataTable/DataRow)
is updated. When you want to commit (Update) the real dbms, you will need
to connect to the database (if no connection exists already), and using the
DataAdapter (ie: SqlDataAdapter) call the appropriate Update/Insert methods
passing either the DataRow, DataTable, or DataSet (forget which is
required).

Once you do get a handle on ADO.Net, I would recommend looking into the
Microsoft Patterns and Practices Enterprise Library Application Blocks (more
specifically, the Data Access Application Block). These blocks help
streamline code you would normally write to help normalize database
connection and access.

HTH,
Mythran

Sep 6 '06 #4

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

Similar topics

14
by: Jacko | last post by:
Hi guys, Say I made a SELECT statement to my sql DB that would return 50 rows that I will use a sqldatareader to access. Instead of iterating through each and every row of the datareader, I'd...
12
by: jaYPee | last post by:
I have currently using a dataset to access my data from sql server 2000. The dataset contains 3 tables that is related to each other. parent/child/grandchild relationship. My problem is it's very...
6
by: Ben Finney | last post by:
Howdy all, Summary: I'm looking for idioms in unit tests for factoring out repetitive iteration over test data. I explain my current practice, and why it's unsatisfactory. When following...
7
by: Ryan | last post by:
OK, here's my setup. I have a treeview control that is populated with records from a Product table, and it allows "checking". This is used for my automatic notification system. Say a particular...
6
by: Ken Fine | last post by:
I'm using SQLDataSource, which generates some kind of dataset, and then I attach that datasource to various data display controls such as DataList and repeater which loop through to the end of the...
0
by: Ohad Weiss | last post by:
Hi all, I've once asked about that topic. but didn't get an answer. I have a dataset based on 4 tables, which have relation between them. The main table presented to the user on textboxes...
1
by: Bmack500 | last post by:
I'm using the following subroutine. The two different XML files are identical with the exception of three additional records in the second one. One has 450 records, and the other has 453. After...
2
by: Shum | last post by:
Hi! i am working on a hospital data base. i have two tables Administration and knowlege base. in Administration i have columns ID, NumberOfDoctors etc, and in KnowlegeBase i have some similar...
0
by: SBMpy | last post by:
Instead of itereating through my half-million plus records, I'm looking for a way to query the records and return a subset of records. Q: Does dbfpy have that functionality? Q: Or is there a...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.