Results 1 to 5 of 5

Thread: compact db via ado+jor ??

  1. #1

    Thread Starter
    Hyperactive Member xray's Avatar
    Join Date
    Jun 2003
    Location
    EgYpT
    Posts
    312

    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
    Attached Images Attached Images  

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: compact db via ado+jor ??

    You cannot compact an open MDB from within VB.
    The folowing samples are from MSDN:
    VB Code:
    1. CompactDatabase Method Example
    2.  
    3. 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.
    4.  
    5. Sub CompactDatabaseX()
    6.  
    7.    Dim dbsNorthwind As Database
    8.  
    9.    Set dbsNorthwind = OpenDatabase("Northwind.mdb")
    10.  
    11.    ' Show the properties of the original database.
    12.    With dbsNorthwind
    13.       Debug.Print .Name & ", version " & .Version
    14.       Debug.Print "  CollatingOrder = " & .CollatingOrder
    15.       .Close
    16.    End With
    17.  
    18.    ' Make sure there isn't already a file with the
    19.    ' name of the compacted database.
    20.    If Dir("NwindKorean.mdb") <> "" Then _
    21.       Kill "NwindKorean.mdb"
    22.  
    23.    ' This statement creates a compact version of the
    24.    ' Northwind database that uses a Korean language
    25.    ' collating order.
    26.    DBEngine.CompactDatabase "Northwind.mdb", _
    27.       "NwindKorean.mdb", dbLangKorean
    28.  
    29.    Set dbsNorthwind = OpenDatabase("NwindKorean.mdb")
    30.  
    31.    ' Show the properties of the compacted database.
    32.    With dbsNorthwind
    33.       Debug.Print .Name & ", version " & .Version
    34.       Debug.Print "  CollatingOrder = " & .CollatingOrder
    35.       .Close
    36.    End With
    37.  
    38. End Sub
    39.  
    40. 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.
    41.  
    42. Sub CompactDatabaseX2()
    43.  
    44.    Dim dbsNorthwind As Database
    45.    Dim prpLoop As Property
    46.  
    47.    Set dbsNorthwind = OpenDatabase("Nwind11.mdb")
    48.  
    49.    ' Show the properties of the original database.
    50.    With dbsNorthwind
    51.       Debug.Print .Name & ", version " & .Version
    52.       Debug.Print "  CollatingOrder = " & .CollatingOrder
    53.       .Close
    54.    End With
    55.  
    56.    ' Make sure there isn't already a file with the
    57.    ' name of the compacted database.
    58.    If Dir("Nwind20.mdb") <> "" Then _
    59.       Kill "Nwind20.mdb"
    60.  
    61.    ' This statement creates a compact and encrypted
    62.    ' Microsoft Jet 2.0 version of a Microsoft Jet version
    63.    ' 1.1 database.
    64.    DBEngine.CompactDatabase "Nwind11.mdb", _
    65.       "Nwind20.mdb", , dbEncrypt + dbVersion20
    66.  
    67.    Set dbsNorthwind = OpenDatabase("Nwind20.mdb")
    68.  
    69.    ' Show the properties of the compacted database.
    70.    With dbsNorthwind
    71.       Debug.Print .Name & ", version " & .Version
    72.       For Each prpLoop In .Properties
    73.          On Error Resume Next
    74.          If prpLoop <> "" Then Debug.Print "  " & _
    75.             prpLoop.Name & " = " & prpLoop
    76.          On Error GoTo 0
    77.       Next prpLoop
    78.       .Close
    79.    End With
    80.  
    81. End Sub

  3. #3

    Thread Starter
    Hyperactive Member xray's Avatar
    Join Date
    Jun 2003
    Location
    EgYpT
    Posts
    312

    Re: compact db via ado+jor ??

    peace be with you

    dear :

    thanks

    but are you sure that this code work with ado

    thanks

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: compact db via ado+jor ??

    Take a look at this samples as well:

    http://vbcity.com/forums/topic.asp?tid=42009

  5. #5

    Thread Starter
    Hyperactive Member xray's Avatar
    Join Date
    Jun 2003
    Location
    EgYpT
    Posts
    312

    Re: compact db via ado+jor ??

    peace be with you

    thanks RhinoBull

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width