1 Attachment(s)
compact db via ado+jor ??
peace be with you
i try to compact db by ado + Microsoft Jet and Replication Objects
and this is the code :
Code:
db_rep.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\WINDOWS\SYSTEM\gcdb.mdb;Jet OLEDB:Database Password=", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\WINDOWS\SYSTEM\gcdb.mdb;Jet OLEDB:Engine Type=5;Jet OLEDB:Database Password="
after run this an runtime error found say :
attached
note : no password for secirty
thanks
Re: compact db via ado+jor ??
You cannot compact an open MDB from within VB.
The folowing samples are from MSDN:
VB Code:
CompactDatabase Method Example
This example uses the CompactDatabase method to change the collating order of a database. You cannot use this code in a module belonging to Northwind.mdb.
Sub CompactDatabaseX()
Dim dbsNorthwind As Database
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
' Show the properties of the original database.
With dbsNorthwind
Debug.Print .Name & ", version " & .Version
Debug.Print " CollatingOrder = " & .CollatingOrder
.Close
End With
' Make sure there isn't already a file with the
' name of the compacted database.
If Dir("NwindKorean.mdb") <> "" Then _
Kill "NwindKorean.mdb"
' This statement creates a compact version of the
' Northwind database that uses a Korean language
' collating order.
DBEngine.CompactDatabase "Northwind.mdb", _
"NwindKorean.mdb", dbLangKorean
Set dbsNorthwind = OpenDatabase("NwindKorean.mdb")
' Show the properties of the compacted database.
With dbsNorthwind
Debug.Print .Name & ", version " & .Version
Debug.Print " CollatingOrder = " & .CollatingOrder
.Close
End With
End Sub
This example uses the CompactDatabase method to change the version of a database. To run this code, you must have a Microsoft Jet version 1.1 database called Nwind11.mdb and you cannot use this code in a module belonging to Nwind11.mdb.
Sub CompactDatabaseX2()
Dim dbsNorthwind As Database
Dim prpLoop As Property
Set dbsNorthwind = OpenDatabase("Nwind11.mdb")
' Show the properties of the original database.
With dbsNorthwind
Debug.Print .Name & ", version " & .Version
Debug.Print " CollatingOrder = " & .CollatingOrder
.Close
End With
' Make sure there isn't already a file with the
' name of the compacted database.
If Dir("Nwind20.mdb") <> "" Then _
Kill "Nwind20.mdb"
' This statement creates a compact and encrypted
' Microsoft Jet 2.0 version of a Microsoft Jet version
' 1.1 database.
DBEngine.CompactDatabase "Nwind11.mdb", _
"Nwind20.mdb", , dbEncrypt + dbVersion20
Set dbsNorthwind = OpenDatabase("Nwind20.mdb")
' Show the properties of the compacted database.
With dbsNorthwind
Debug.Print .Name & ", version " & .Version
For Each prpLoop In .Properties
On Error Resume Next
If prpLoop <> "" Then Debug.Print " " & _
prpLoop.Name & " = " & prpLoop
On Error GoTo 0
Next prpLoop
.Close
End With
End Sub
Re: compact db via ado+jor ??
peace be with you
dear :
thanks
but are you sure that this code work with ado
thanks
Re: compact db via ado+jor ??
Re: compact db via ado+jor ??
peace be with you
thanks RhinoBull