How to create or compress an Access database using pure encoding (4)

Source: Internet
Author: User
Bytes (byValdbFileName, byValDbVer, byValSavePath) Compressed database file 0 is access971 is access2000OnErrorresumenextIfRight (SavePath, 1) OrRight (SavePat

Set Ca = Nothing CreateDBfile = True End If End function Public function CompactDatabase (byVal dbFileName, byVal DbVer, byVal SavePath) compressed database file 0 is access 97 1 is access 2000 On Error resume next If Right (SavePath, 1) Or Right (SavePat

Set Ca = Nothing

CreateDBfile = True

End If

End function

Public function CompactDatabase (byVal dbFileName, byVal DbVer, byVal SavePath)

'CompressionDatabaseFile

'0 is access 97

'1 is access 2000.

On Error resume next

If Right (SavePath, 1) <> "" Or Right (SavePath, 1) <> "/" Then SavePath = Trim (SavePath )&""

If Left (dbFileName, 1) = "" Or Left (dbFileName, 1) = "/" Then dbFileName = Trim (Mid (dbFileName, 2, Len (dbFileName )))

If DbExists (SavePath & dbFileName) Then

Response. Write ("sorry, thisDatabaseAlready exists! ")

CompactDatabase = False

Else

Dim Cd

Set Cd = Server. CreateObject ("JRO. JetEngine ")

If Err. number <> 0 Then

Response. Write ("NoCompression, Please check the error message

"& Err. number &"

"& Err. Description)

Err. Clear

Exit function

End If

If DbVer = 0 Then

Call Cd. CompactDatabase ("Provider = Microsoft. Jet. OLEDB.3.51; Data Source =" & SavePath & dbFileName, "Provider = Microsoft. Jet. OLEDB.3.51; Data

Source = "& SavePath & dbFileName &". bak. mdb; Jet OLEDB; Encrypt Database = True ")

Else

Call Cd. CompactDatabase ("Provider = Microsoft. Jet. OLEDB.4.0; Data Source = "&

SavePath & dbFileName, "Provider = Microsoft. Jet. OLEDB.4.0; Data Source = "&

SavePath & dbFileName & ". bak. mdb; Jet OLEDB; Encrypt Database = True ")

End If

'Delete the oldDatabaseFile

Call DeleteFile (SavePath & dbFileName)

'ConvertCompressionAfterDatabaseFile Restoration

Call RenameFile (SavePath & dbFileName & ". bak. mdb", SavePath & dbFileName)

Set Cd = False

CompactDatabase = True

End If

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.