Re: ADOX not deleting on first attempt



Bernard wrote:
Hi group,

I'm trying to delete some tables (in my test case all tables) using
adox.

Problem is, it takes a couple of "runs" to delete all the table.
Is there a reason for this? Is there any dependencies that does not
allow the table to be deleted and if so, why don't I get an error
(even when I check ADODB.Connection.Error)?

This seems to be happening with views also.

Here's the code:

Dim catalog As ADOX.catalog
Set catalog = New ADOX.catalog

Dim table As ADOX.table
Dim tableNode As IXMLDOMNode

Dim index As ADOX.index
Dim deleteCount As Integer

' Set active ADO Connection
catalog.ActiveConnection = g_cn

'Do
'deleteCount = 0
For Each table In catalog.Tables
' Don't try to delete views or system tables
If StrComp(table.Type, "TABLE", vbTextCompare) = 0 Then
' Drop the table
catalog.Tables.Delete table.Name
'deleteCount = deleteCount + 1
End If
Next
'Loop While deleteCount > 0

Is this a Jet database? If so, you may be running afoul of the Jet
delayed-write optimization feature:
http://support.microsoft.com/?kbid=240317
http://support.microsoft.com/kb/200300


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


.



Relevant Pages

  • ADOX not deleting on first attempt
    ... Dim catalog As ADOX.catalog ... Dim deleteCount As Integer ... ' Set active ADO Connection ...
    (microsoft.public.data.ado)
  • Re: Add text to begining of cells within a range based on specified criteria
    ... newsgroups one of which was the word newsgroup. ... Are you manipulating an Excel workbook with VBA code running in Excel, ... Dim sStart As String ... Dim bReplace As Boolean ...
    (microsoft.public.word.vba.general)
  • Re: Median calculation
    ... Already answered in another newsgroup to which you posted the same question. ... Dim rs As DAO.Recordset ... 'Open a recordset on the table. ... DMedian = rs ...
    (microsoft.public.access.queries)
  • RE: Determine what row is currently selected
    ... Please reply to newsgroup only. ... Sub cmd_GotoTask_Click ... Dim mycolumns As Range ... intRowPointer = C.Row ...
    (microsoft.public.excel.programming)
  • Re: VBScript and asp...
    ... I want to do this by normal asp with VBScript. ... Dim objDomain, vDomain, vUserName ... > There was no way for you to know it, but this is a classic asp newsgroup. ...
    (microsoft.public.inetserver.asp.general)