压缩Access2000(带密码)的数据库,出现上述错误,是什么原因?该如何解决?
(该引用的均已引用。)在程序起动时调用了打开Access数据库的过程,如下:dbPath = App.Path + "\students.mdb"
Pass = "20030101"
Set dbObj = New ADODB.Connection
dbConnectionString = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & dbPath & ";"
dbConnectionString = dbConnectionString & "PWD=" & Pass & ";"
dbObj.Open dbConnectionString压缩时的代码: Currentfile = App.Path & "\students.mdb"
Backfile = App.Path & "\stubak.mdb" conStr1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Currentfile & ";jet oledb:database password=20030101"
conStr2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Backfile & ";jet oledb:database password=20030101"
dbObj.Close '是不是这个地方代码不对?请高手指点!
dbConnectionString = ""
JRO.CompactDatabase conStr1, conStr2
Kill Currentfile
Name Backfile As Currentfile
(该引用的均已引用。)在程序起动时调用了打开Access数据库的过程,如下:dbPath = App.Path + "\students.mdb"
Pass = "20030101"
Set dbObj = New ADODB.Connection
dbConnectionString = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & dbPath & ";"
dbConnectionString = dbConnectionString & "PWD=" & Pass & ";"
dbObj.Open dbConnectionString压缩时的代码: Currentfile = App.Path & "\students.mdb"
Backfile = App.Path & "\stubak.mdb" conStr1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Currentfile & ";jet oledb:database password=20030101"
conStr2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Backfile & ";jet oledb:database password=20030101"
dbObj.Close '是不是这个地方代码不对?请高手指点!
dbConnectionString = ""
JRO.CompactDatabase conStr1, conStr2
Kill Currentfile
Name Backfile As Currentfile
http://expert.csdn.net/Expert/topic/2031/2031535.xml
怎样以独占方式打开?能不能说仔细点?
我是初学者,不太明白。
看看下面的文章
Compact and repair databases in ADOIn a previous tip (Compact and repair Jet databases with DAO), we showed you how to compact and repair a database with DAO. However, if you're using ADO, you can also compact and repair Access databases using Jet and Replication Objects (JRO).
To take advantage of JRO's CompactDatabase method, which will also repair the database, set a reference the JRO library, Microsoft Jet And Replication Objects 2.1 Library. Next, declare and set a JetEngine object variable, like so
Dim JRO As JRO.JetEngineSet JRO = New JRO.JetEngine
JRO.CompactDatabase _"Provider=Microsoft.Jet.OLEDB.4.0;" _& "Data Source=C:\myData1.mdb", _"Provider=Microsoft.Jet.OLEDB.4.0;" _& "Data Source=C:\myDataNewName.mdb"_& ";Jet OLEDB:Engine Type=4"
This command follows similar syntax as DAO's CompactDatabase method-you must provide the old database name and the new database name. In the case of JRO, however, you must also provide a valid connection string, as well as indicate the type of Jet engine to compact the database as. We used 4 to create a Jet Version 3.x database suitable for Access 97 users. If you work with Access 2000 use the value 5 to create a Jet Version 4.x database.
还是要在压缩前断开所有连接?程序中连接Access 的连接已经断开了呀?
dbObj.Close '是不是这个地方断开连接的代码不对?
dbConnectionString = ""