Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RepairDatabase, CompactDatabase 1

Status
Not open for further replies.

TondoBoy

Programmer
Mar 22, 2001
31
0
0
US
Help, please.

Anyone knows if there are equivalent to DAO RepairDatabase and CompactDatabase syntax in ADO. I am converting DAO codes to ADO. The following is repairing and compacting access a database in DAO:

DBEngine.RepairDatabase Name.MDB
DBEngine.CompactDatabase Name.MDB, Another.MDB


Thanks in advance.....
 
I don't know of any way in ADO to do that, as it's specific to MS Access.

What I've done in the past is create a very small application which use ODBC/JET to call those functions. Have your users run it every so often, or when they start getting strange results.

In the meantime, you ought to be developing against a real database. See about switching to the MSDE (desktop version of SQL Server 7).

I guess you can tell I'm not a big fan of Access :-(

Chip H.
 
I've use the code below to compact the database:

'Compact database
Dim JRO As JRO.JetEngine, NewStrCon As String
Set JRO = New JRO.JetEngine

If con.State Then con.Close ' close db if open
NewStrCon = Replace(StrCon, dbName, App.Path + "\tmp.mdb") 'create new connection string
JRO.CompactDatabase StrCon, NewStrCon 'Compact database
Kill dbName 'delete old db
Name App.Path + "\tmp.mdb" As dbName 'rename compacted as the old
con.Open StrCon 'open db

Sunaj
 
Sunaj,
Thanks for the information. I am using VB6 and trying to compact access database. What reference did you use for the jetengine. I cannot invoke it on the code....Again, thanks...
 
Hi,

I use VB6 too. Reference to : Microsoft Jet and Replication Objects 2.5 Library (MSJRO.dll)

Sunaj

 
I'm trying to do the same thing with msjro.dll version 2.6 and keep getting an ISAM error. I'm using an access 2000 db and put the engyne type to 5. Anyone know why??
 
Maybe the engine should be 4 eg

db1.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
" Data Source = " & App.Path & "\databasename.mdb;Jet OLEDB:Database Password=YourPassword;"

I don't know though as I am just learning myself. This works for my Access 2000 database.

-Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top