Griffiths, Richard
R.Griffiths at bury.gov.uk
Fri Jul 22 08:08:33 CDT 2005
Hi
With a dataset you can do this
Dim drows() as datarow = ds.tables(0).Select("ClientID = " & intID) to
find a specific record
Then can use drows.count or
For each dRow in drows
'' do something
Next
Both datareaders and datasets allow field references dr("ClientID") and
ds("ClientID")
Hope this helps
Richard
-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of John W. Colby
Sent: 22 July 2005 13:31
To: dba-vb at databaseadvisors.com
Subject: RE: [dba-VB] Vb.net ADO Equivelent to recordset
Alright, in this specific case it sounds like I need a data reader.
However I am accustomed to working with datasets where you can "seek" or
"find" specific records. So far I haven't found anything like that.
The object loads all the records into an array apparently and then you
can go to a specific row of the array, but only by the integer index.
What am I missing? Is there not something similar to rst.find
([fieldname]=somevalue)
And what about accessing the data by field name?
MyVar = rst!VarName or
MyVar = rst(VarName)
Both of these constructs are just essential. How can you pull data out
of specific fields of a table without such constructs unless you work
with ordinal field positions which we have all been trained NEVER to do?
John W. Colby
www.ColbyConsulting.com
Contribute your unused CPU cycles to a good cause:
http://folding.stanford.edu/
-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Mike & Doris
Manning
Sent: Friday, July 22, 2005 8:11 AM
To: dba-vb at databaseadvisors.com
Subject: RE: [dba-VB] Vb.net ADO Equivelent to recordset
In .Net, you use DataAdapters, Datasets, and DataReaders to work with
data. A DataAdapter has Select, Insert, Update, and Delete commands.
You use the DataAdapter to fill a Dataset. A Dataset can contain as
many tables as you like. Each Table is indexed according to the order
it is added to the dataset.
A DataReader is a forward only dataset used when you just want to read
through the data once.
To work with the individual rows of a dataset, you would do the
following.
Dim dt as Table 'Variable to hold the Dataset table you want to work
with
Dim dr as Row 'Variable to refer to the row in the Dataset table.
Dt = ds.Tables(0) 'Set the DataTable variable to the
Dataset
table
For Each dr in dt 'Loop through the rows in the
dataset
'Do something 'Do something
Next dr 'Advance to the next row
Doris Manning
Database Administrator
Hargrove Inc.
-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of John W. Colby
Sent: Friday, July 22, 2005 7:27 AM
To: dba-vb at databaseadvisors.com
Subject: [dba-VB] Vb.net ADO Equivelent to recordset
I need to manipulate a recordset like I would in VBA
with rst
.findfirst
SomeVar = !SomeField
SomeVar2 = !SomeField2
end with
What is the equivalent in ADO / .net? I do not need to bind this to a
control, and all of the examples I am finding for .NET assume I just
want to bind it to a grid or a list or something.
In fact I do want to bind it to a class if that is possible. I am
building a class pair where one class represents an individual record,
and the parent class represents a table (an indexed collection of the
record classes). The first class has properties (variables) for each
field in the table, and the init will load the values in. The second
class needs to open the "recordset", and then start instantiating the
first class, initializing with data from a given record, storing in a
collection and moving to the next record.
I have done all of this in ADO in VBA using the adodb.recordset object
but don't find the equivalent in .net.
John W. Colby
www.ColbyConsulting.com
Contribute your unused CPU cycles to a good cause:
http://folding.stanford.edu/
_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com
_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com
_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com