ADOX.Catalog Very Slow Processing

G

Guest

The function below checks to if a table exists. The
problem is that when the program hits "For each tbl" line
for the first time ito hangs for a long time and then
quicly processes the loop. Is there another way to do this
that would be faster (staying with ADO programming)? Am I
doing something inefficient?

The table are on a server and the code below runs locally.

----------------
Function TableExists(db As ADODB.Connection, strTableName
As String) As Boolean

On Error Resume Next

Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Dim Counter As Long

TableExists = False

Set cat = New ADOX.Catalog
cat.ActiveConnection = db

For Each tbl In cat.Tables
If tbl.Name = strTableName Then
TableExists = True
Exit For
End If
Next tbl

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top