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

    Exclamation How can I use OLEDB in VB6.0 directly without ADODB


    Currently I am using ADODB for connect with the database, and Recordset to add and update in database, i want to use OLEDB to interact with the database in VB6.0. How I can use OLEDB in VB6.0 for connection and updating the database from my Application. I do not want to use ADODB.

    ADODB work with the help of OLDDB from the behind but this time i want to use it directly

    Even i do not will it is possible or not.

    Please help me out its very argent for me.

    Thanks in advance.
    Last edited by mishra_sunil22; April 1st, 2008 at 06:46 AM.

  2. #2
    Join Date
    Jul 2005

    Re: How to use OLEDB in VB6.0

    I wish I had my VB installed but the system just crashed, here is some code to start you off.

    Place this code in a module

    Option Explicit
    Public Cnn As ADODB.Connection
    Public Rs As ADODB.Recordset
    Public MyDbPath As String
    Public Sub ConnectToDatabase()
    Set Cn = New ADODB.Connection
    Cnn.Provider = "Microsoft.Jet.OLEDB.4.0;Jet OLEDB"
    CnnArt.Open (MyDbPath)
    Set Rs = New ADODB.Recordset
    Rs.Open "Login", Cnn, adOpenDynamic, adLockOptimistic, adCmdTable
    'this should open a table named Login in the database
    End Sub
    Then you need to access a form, say a login to add more users, etc. To access the database table, use this code write this code in the form;

    Form Load()
    WITH rsLogin                             ' This is the login table
                  .AddNew                                       'Adds new data to the table
                  !Password = txtPassword.Text    ' Password field in table
                  !UserName = txtUserName.Text
    End WITH
    End Sub
    If it doesn't work then I missed a step somewhere in the form. A coleague will help, am sure.

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.