Re: how to reference feild data -
- From: "Richard Mueller" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 3 Jan 2006 17:44:33 -0600
barret bonden wrote:
> Playing about in VB.NET using classic ADO and I cant see how to reference
> feild data - the !fieldname
>
> syntax I'm used to in Access doesn't seem to work -
>
>
>
> Imports System.Data
>
> Imports ADODB
>
> Imports System.Data.OleDb
>
> Dim conn As New ADODB.Connection
>
> Dim rs As ADODB.Recordset
>
> Dim v As String, i As Int16
>
> conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\t.mdb")
>
> rs = conn.Execute("select * from main")
>
> rs.MoveFirst()
>
> Do While Not rs.EOF
>
> ' ListBox1.Items.Add(rs!last) ' DOES NOT WORK
>
> rs.MoveNext()
>
> Loop
>
> For i = 0 To rs.Fields.Count - 1
>
> ' ListBox1.Items.Add(rs.Fields(i).Name)
>
> 'ListBox1.Items.Add(rs.Fields(i).Name)
>
> Next
Hi,
I use (assuming the field name is "Last"):
rs.Fields("Last").Value
Also, you can experiment to find the index with:
For i = 0 To rs.Fields.Count - 1
ListBox1.Items.Add(rs.Fields(i).Name & ": " & rs.Fields(i).Value)
Next
In any case, you want the Value property, not the Name property, but you can
reference the proper field by specifing the name or the index.
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
.
- Follow-Ups:
- Re: how to reference feild data -
- From: barret bonden
- Re: how to reference feild data -
- References:
- how to reference feild data -
- From: barret bonden
- how to reference feild data -
- Prev by Date: Re: Identity_Insert
- Next by Date: RE: Using Rich Text formating with InfoPath
- Previous by thread: how to reference feild data -
- Next by thread: Re: how to reference feild data -
- Index(es):
Relevant Pages
|