ado .net

T

Terry Knight

Hello,

I'm new to ADO .NET and I'm still thinking back to ADO in VB6 using
recordset. Now I have added the ADODB reference so I can still use if for
some of the program that I'm programming but I would like to get into ADO
..NET.

Here's my question. In VB6 you could call a single field:

textbox = rs("field")

can you do this in ADO .net???

Now I know about the FILL function for ADO .net but there's a couple things
that I'd like to do but just using 1 or 2 of the fields not all of them.
 
K

Kirk

Terry,

ADO.net actually has 2 object that 'replace' the
functionality of the recordset. The first option is the
one I think you have mentioned, the DataAdapter. Using the
DataAdapter you can fill a dataset with the result from a
query (data is all loaded Client side in a single step).
The other option is the DataReader. You can use the
DataReader to do the same sort of record by record loop
that the adodb.recordset allowed.

a brief sample (in vb.net):
**************************
dim cmd as new SQLClient.SQLCommand
(SomeSQLString,SomeConnecion)
dim dr as SQLClient.SQLDataReader

dr = cmd.executeReader

do while dr.read()
' right here you can place the data into your textboxes
or whatever
textbox1.text = dr.item("fieldName")
loop

dr.close
**************************
Unlike the recordset, be careful to ALWAYS close your
datareader. It locks up the connection until you do.

Kirk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top