Re: ADOX not deleting on first attempt
- From: Bernard <bernard.herrok@xxxxxxxxx>
- Date: Thu, 8 May 2008 23:49:21 -0700 (PDT)
On May 8, 11:46 pm, "Bob Barrows [MVP]" <reb01...@xxxxxxxxxxxxxxx>
wrote:
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=240317http://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.
Thanks Bob. Is there a way to force a write after each command?
If not, have a look at the commented lines of my code in my first
post.
The only way I can get it to drop the tables is by running the drop
statements for each table and then do another pass on the database
dropping the tables until it does a full pass without dropping
anything.
This is not bullet proof, but seems to be doing the job. Is this a
common workaround for lazy-write issue?
.
- Follow-Ups:
- Re: ADOX not deleting on first attempt
- From: Bob Barrows [MVP]
- Re: ADOX not deleting on first attempt
- References:
- ADOX not deleting on first attempt
- From: Bernard
- Re: ADOX not deleting on first attempt
- From: Bob Barrows [MVP]
- ADOX not deleting on first attempt
- Prev by Date: Re: ADOX not deleting on first attempt
- Next by Date: Re: ADOX not deleting on first attempt
- Previous by thread: Re: ADOX not deleting on first attempt
- Next by thread: Re: ADOX not deleting on first attempt
- Index(es):