Re: how to reference feild data -



Thanks very much - worked fine.


"Richard Mueller" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:OMB0n%23LEGHA.1312@xxxxxxxxxxxxxxxxxxxxxxx
> 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
>
>


.



Relevant Pages