Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compacting A2K with VB6 JRO

Status
Not open for further replies.

jadams0173

Technical User
Feb 18, 2005
1,210
I have a couple issues with the following code.

1. After the compact the password is not what I have specified in the connstringDest string.

2. If I step thru the code, I still have the password issue but the file size is correct. If I let it run at "speed" I end up with a DB with 0 KB in it that I still can't open.

Can anyone help please?

Code:
Public Function CompactDB(pFile As String) As Boolean
On Error GoTo ErrH
Dim conn As New JRO.JetEngine
Dim ConnstringSorg As String, ConnstringDest As String

' Ensure file is not read only
SetAttr pFile, vbNormal
ConnstringSorg = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source=" & pFile & ";" & _
                "Jet OLEDB:Database Password=word;"
  
ConnstringDest = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
  "G:\mypath\Temp.mdb; Jet OLEDB:Database Password=word:Engine Type=5;"
  

Screen.MousePointer = vbHourglass
conn.CompactDatabase ConnstringSorg, ConnstringDest


'compact and kill the file
Kill pFile
FileCopy "G:\mypath\Temp.mdb", pFile
Kill "G:\mypath\Temp.mdb"
Screen.MousePointer = vbDefault
Set conn = Nothing
CompactDB = True
Exit Function
ErrH:
Screen.MousePointer = vbDefault
Debug.Print Err.Description
End Function
 
I figured it out!! I had a little problem with the ConnstringDest string. The 0 KB was misleading. The data was there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top