Check if table exist

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • claudy
    New Member
    • Sep 2006
    • 2

    Check if table exist

    I would like to check in VB code if a table exist. How do I do that?
  • phpmaet
    New Member
    • Sep 2006
    • 27

    #2
    Hi,
    could you try this code?. i hope it's very useful for you.


    Code:
    Public Function TableExistsADO(ByVal strDB As String, strTable As String) As  Boolean  
      
    On Error GoTo Hell  
    
    Dim RS As Recordset  
      
    Set RS = New Recordset  
      
    RS.Open "SELECT * FROM " & strTable & " WHERE 1=0", _  
      
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & strDB  
      
    TableExistsII = True  
      
    Exit_For:  
       
    If RS.State = adStateOpen Then RS.Close  
      
    Set RS = Nothing  
      
    Exit Function  
      
    Hell:  
      
    GoTo Exit_For  
      
    End Function
    Thanks

    Comment

    Working...