CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Field Contents

  1. #1
    Guest

    Field Contents

    I have the names of two fields in a database file. I want to get each entry in each field, and I want to do this without using any controls, just coding. How can I achieve this? Thanks.


  2. #2
    Guest

    Re: Field Contents

    In Project, References menu select Microsoft ActiveX Data Objects 2.0 Library. In General Declaration place (Sample works with Sample db Biblio.mdb):

    private cn as Connection
    private rs as Recordset



    In Form_Load event:

    private Sub Form_Load()
    Dim FirstField 'you need to decide what type
    Dim SecondField
    set cn = new Connection
    cn.CursorLocation = adUseClient
    cn.Open "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\Biblio.mdb;"

    set rs = new Recordset
    rs.Open "select Au_ID,Author from Authors", cn, adOpenStatic, adLockOptimistic
    FirstFileld = rs!Au_ID
    SecondField = rs!Author
    'you have your fields in variables now.
    'you can use methods of Recordset object, like MoveNext, MoveLast and so on.



    Vlad


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured