Re: how to reference feild data -

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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

  • Re: VB.Net not building added file
    ... What was happening was that I still had to manually add a reference to ... I would have thought that if the project was building the .dll, ... Imports System.Data.SqlClient ... Dim SqlConnection1 As SqlConnection ...
    (microsoft.public.dotnet.languages.vb)
  • Re: VB.Net not building added file
    ... What was happening was that I still had to manually add a reference to it. ... Imports System.Data.SqlClient ... Dim SqlConnection1 As SqlConnection ... Dim myDbObject As New DbObject ...
    (microsoft.public.dotnet.languages.vb)
  • Re: how to reference feild data -
    ... >> syntax I'm used to in Access doesn't seem to work - ... >> Imports System.Data ... >> Dim conn As New ADODB.Connection ... > reference the proper field by specifing the name or the index. ...
    (microsoft.public.data.ado)
  • Re: SQLXMLBulkLoad Question (Please help)
    ... Imports SQLXMLBULKLOADLib ... I have reference to Interop.SQLDMO and Interop.SQLXMLBULKLOADLib ... >> Dim dsOld As New DataSet ...
    (microsoft.public.sqlserver.xml)
  • RE: open arguments.
    ... The original to add a complete new quote, one to edit a quote and one to ... Dim rst As Recordset ... This opens the form specified by stDocName in data entry mode and passes the ... You want to store your reference so poke it into the reference field. ...
    (microsoft.public.access.modulesdaovba)