|
-
Aug 3rd, 1999, 03:07 PM
#1
Thread Starter
Addicted Member
Does anyone know how to run Access compact and repair database from VB6 code? Also can you run an Access report using VB code? Thanks for your help.
-
Aug 3rd, 1999, 03:42 PM
#2
For Repair you can use:
DBEngine.RepairDatabase "C:\MyDB.mdb"
For Compacting:
Code:
Dim strTempDB As String
Dim strDBName As String
strDBName = "C:\MyDB.mdb"
strTempDB = "C:\Temp.mdb"
DBEngine.CompactDatabase strDBName, strTempDB
Name strTempD As strDBName
Regards,
------------------
Serge
Software Developer
[email protected]
[email protected]
-
May 21st, 2003, 10:50 AM
#3
Hyperactive Member
Hello Serge. I tried using this codes but I think i am missing a project reference or component. Could you please tell me what reference or component I should include with my project? Thanks a bunch.
Top Tip: You can make friends and impress the opposite sex at geeky cocktail parties by saying "DB" instead of database. - Karl Moore
-
Jul 25th, 2003, 11:32 PM
#4
Hyperactive Member
DbEngine
VB Code:
Dim strTempDB As String
Dim strDBName As String
strDBName = "C:\MyDB.mdb"
strTempDB = "C:\Temp.mdb"
DBEngine.CompactDatabase strDBName, strTempDB ' What is This?
Name strTempD As strDBName
Any on know what is DbEngine?
-
Jul 26th, 2003, 02:15 AM
#5
You need to set a reference to Microsoft DAO Library.
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
Jul 26th, 2003, 04:14 AM
#6
Hyperactive Member
-
Jul 26th, 2003, 07:04 PM
#7
I'm not sure how to do it with ADO. Have a look at this post and see if it helps:
http://www.vbforums.com/showthread.p...hreadid=201558
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
Jul 27th, 2003, 03:45 PM
#8
Frenzied Member
VB Code:
Public Function CompactDatabase(strFileName As String) As Long
' Add the references
' Microsoft Jet and Replication Objects 2.x Library
Screen.MousePointer = vbHourglass
Dim msg As String
Dim strFileNameBackup As String
Dim JRO As JRO.JetEngine
strFileNameBackup = Left(strFileName, Len(strFileName) - 3) & "~db"
On Local Error Resume Next
Kill strFileNameBackup
On Error GoTo ErrorLine
Name strFileName As strFileNameBackup
Set JRO = New JRO.JetEngine
JRO.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFileNameBackup, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFileName & ";Jet OLEDB:Engine Type=5"
Kill strFileNameBackup
Screen.MousePointer = vbDefault
Exit Function
ErrorLine:
CompactDatabase = Err.Number
End Function
oh1mie/Vic

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
|