Ado table exist

' Name: Ado Table Exist

' Description:Function Check if exist a

' Table in Access Database.

' Insert adodb.net in Your Project

Module Module1

    Public rstCat As ADODB.Recordset

    Public m_con As ADODB.Connection

    Public dbPName As String

    Public ConnectString As String

    Public Function ADOTableExists(ByVal strTable As String, ByVal cnConnection As String) As Boolean

        Dim cnn1 As ADODB.Connection

        Dim strCnn As String

        Dim rstSchema As ADODB.Recordset

        ' Open connection.

        strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & cnConnection

        cnn1 = New ADODB.Connection()

        cnn1.CursorLocation = ADODB.CursorLocationEnum.adUseClient

        cnn1.Open(strCnn)

        ' Open the schema information

        rstSchema = cnn1.OpenSchema(ADODB.SchemaEnum.adSchemaTables)

        'use Find to check if the pirticular tab

        ' le is returned or not

        rstSchema.Find("table_name like '" & strTable & "'")

        'If the table is not found it returns -3

        '

        If (rstSchema.AbsolutePosition < 0) Then

            ADOTableExists = False

        Else

            ADOTableExists = True

        End If

        cnn1.Close()

        cnn1 = Nothing

    End Function

End Module