|
-
Oct 9th, 2000, 07:52 AM
#1
Hey,
I'm using the following code to (try to) compact a database.
Private Sub Compact_Database()
Dim jro As jro.JetEngine
Dim OldConn As String
Dim NewConn As String
Set jro = New jro.JetEngine
OldConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\PROJECTEN\AdmICS\Databases\Test.mdb;PWD=test"
NewConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\PROJECTEN\AdmICS\Databases\TestComp.mdb;PWD=test"
jro.CompactDatabase OldConn, NewConn
End Sub
Coming to the last line it gives a fault:
'Could not find installable ISAM'.
Can anybody tell me with this fault means or how I can alter
my code in order by to make it work.
-
Oct 9th, 2000, 09:25 AM
#2
Addicted Member
I always do something like this, simply pass the original name and the name of the compressed database to the DBEngine.CompactDatabase method.
Don't forget to backup first
Beware !!!
Untested code, typed it straight into this box cause our internet pc's are not on our network, I think it's correct though.
Beware !!!
Code:
Dim strTemp As String
Dim strOriginal As String
Dim strMessage As String
Dim lngOldSize as Long
Dim lngNewSize as Long
strTmp = pstrDataBaseDir & pstrDataBaseName
strOriginal = pstrDatabaseDir & pstrDatabaseName & "org"
lngOldSize = FileLen(strTmp)
Name strTmp As strOriginal
strCompressed = strTmp
' Compress database to it's original name.
DBEngine.CompactDatabase strOriginal, strCompressed, , , ";PWD=" ' Here your Password
lngNewSize = FileLen(strCompressed)
strMessage = "Action completed" & vbLf & vbLf & _
"Old size: " & CStr(lngOldSize) & _
"New size: " & CStr(lngNewSize) & vbLf
MsgBox strMessage
Remember to make sure there are no connections to the database left in the program and make sure there are no users in the database anymore.
Regards,
Laurens
Using VB5 Enterprise edition SP3
VB6 Enterprise edition SP5
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|