FILE: Adovb.exe Demonstrates How to Use ADO with Visual Basic

Last reviewed: March 6, 1998
Article ID: Q172403
The information in this article applies to:
  • ActiveX Data Objects (ADO) included with:

        - Microsoft Visual Basic Professional and Enterprise Editions for
          Windows, version 5.0
    

SUMMARY

Adovb.exe is a self-extracting compressed file containing sample code that demonstrates how to use ActiveX Data Objects (ADO) within Visual Basic.

MORE INFORMATION

The following files is available for download from the Microsoft Software Library:

 ~ Adovb.exe (size: 167943 bytes) 

For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q119591
   TITLE     : How to Obtain Microsoft Support Files from Online Services

What ADOVB Demonstrates

ADOVB demonstrates proper use of output and return parameters (for SQL Server), and opening a parameterized recordset for both a Access and SQL Server data sources. Also included is a generic template for error handling with ADO code:

   Private Sub cmdTemplate_Click()
      Dim Conn1 As adodb.Connection

      On Error GoTo VbError   ' Trap (non-ADO) error/exceptions

      ' Create Connection Object (using early binding)
      Set Conn1 = new ADODB.Connection


      On Error GoTo AdoError  ' Trap any error/exception

      Conn1.ConnectionString = AccessConnect
      Conn1.Open

      '----------------------
      ' YOUR CODE GOES HERE!
      '----------------------

      ' Successful Shutdown
      Conn1.Close

   Done:
      ' Miscellaneous (graceful) Cleanup
      On Error Resume Next

      Set Conn1 = Nothing

      Exit Sub

   ' ADO Error/Exception Handler
   AdoError:
      ' Save Error Information!
      ErrNumber = Err.Number
      ErrSource = Err.Source
      ErrDescription = Err.Description

      AdoErrorEx List1, Conn1

   ' Non-ADO Native error/exception handler
   VbError:
      VbErrorEx List1, ErrNumber, ErrSource, ErrDescription
      GoTo Done

   End Sub

About the ADO* Series of Samples

This is one of several identical samples implemented using ADO within various products, as listed below. The advantage is that these articles have an identical interface/functionality, demonstrating both the similarities differences in using ADO with different languages / mechanisms.

QNumber                           Title
------- ----------------------------------------------------------------
Q172403  FILE: Adovb.exe Demonstrates How to Use ADO with Visual Basic
Q174565  FILE: Adovc.exe Demonstrates How to Use ADO with Visual C++
vernettp
Keywords          : kbcode adovb
Technology        : odbc
Version           : WINDOWS:5.0
Platform          : WINDOWS
Issue type        : kbfile


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 6, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.