CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 1999
    Posts
    3

    ADO Connectivity

    Hi
    I am new VB , I am doing Database work using ADO in VB, I want some Sample which help to start. Any one could suggest a good book as well as send some good sample codes .

    thanks in advance
    cheers
    Arunesh


  2. #2
    Join Date
    Jun 1999
    Posts
    32

    Re: ADO Connectivity

    Here's a sample ....
    In a .bas module:

    public conn as new ADODB.Connection
    public rsRecordset as new ADODB.Recordset

    public Sub OpendB()

    set conn = new ADODB.Connection
    set rsRecordset = new ADODB.Recordset
    With conn
    .Provider = "Microsoft.jet.oledb.3.51"
    .Open App.Path & "\MyDatabase.mdb"
    End With

    rsRecordset.Open SQLStatment, conn, adOpenStatic, adLockOptimistic

    End Sub

    public Sub ClosedB()

    rsRecordset.Close
    conn.Close

    End Sub




    I chose an Jet style database to open the connection to as the provider. Different ones require different syntax but mdb's seem to be the most common.

    You can address the opened recordset like this:
    rsRecordset.MoveFirst etc and set/retrieve a field like rsRecordset!FieldName

    Don't forget to include Microsoft ActiveX Data Object 2.0 Library in your Project References and possibly Microsoft ADO Data Control 6.0 (OLEDB) as a component.

    Hope this helps a bit



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