VB 6.0 ADO and Access


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: VB 6.0 ADO and Access

  1. #1
    Jim Burak Guest

    VB 6.0 ADO and Access


    I was wanodering if anyone knew how to check to see if a table exists in an
    Access database using VB 6.0 ADO programmatically?

    Thanks,

    JB

  2. #2
    Steve Abel Guest

    Re: VB 6.0 ADO and Access


    Try this function:

    You will need to set a reference to the 'Microsoft ADO Ext. 2.6 for DDL and
    Security' dll (msadox.dll) for this to work.

    Function TableExists(ByVal TableName As String, _
    DBConnection As ADODB.Connection) As Boolean
    Dim Cat As ADOX.Catalog
    Dim tmpTable As ADOX.Table

    If DBConnection.State <> adStateOpen Then _
    Err.Raise 32000, "TableExists", _
    "Invalid 'DBConnection'. Must be a valid Open ADO Connection object."

    Cat.ActiveConnection = DBConnection

    For Each tmpTable In Cat.Tables
    If StrComp(tmpTable.Name, TableName, vbTextCompare) Then
    TableExists = True
    Exit Function
    End If
    Next tmpTable
    End Function

    Good luck,
    Steve


    "Jim Burak" <jim.burak@cevp.com> wrote:
    >
    >I was wanodering if anyone knew how to check to see if a table exists in

    an
    >Access database using VB 6.0 ADO programmatically?
    >
    >Thanks,
    >
    >JB



  3. #3
    Paul Clement Guest

    Re: VB 6.0 ADO and Access

    On 28 Jun 2001 06:51:48 -0700, "Jim Burak" <jim.burak@cevp.com> wrote:


    I was wanodering if anyone knew how to check to see if a table exists in an
    Access database using VB 6.0 ADO programmatically?

    Thanks,

    JB

    A simple SQL statement will work as well:

    SELECT MSysObjects.*
    FROM MSysObjects
    WHERE MSysObjects.Name="Table1"


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

  4. #4
    andy oneill Guest

    Re: VB 6.0 ADO and Access


    "Jim Burak" <jim.burak@cevp.com> wrote:
    >
    >I was wanodering if anyone knew how to check to see if a table exists in

    an
    >Access database using VB 6.0 ADO programmatically?
    >
    >Thanks,
    >
    >JB


    There's a system table, msysobjects you can select out of.
    Take a look at it.
    I think attached tables have a different type to local ones.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center