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!

CompactDatabase problem 1

Status
Not open for further replies.

hansu

Programmer
Mar 12, 2002
89
0
0
I want to provide the user with the possibility to compact an Access97 Database from the application.
Now I am stuck with the following problem:
When I run the following code error -2147467259 is generated: 'Couldn't open database. Either the database isn't recognized by the application or it is damaged' (Which is not the case)
Code:
Dim jroEngine As JRO.JetEngine, strSourceDB$, strDestDB$
Set jroEngine = New JRO.JetEngine
strSourceDB = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Development\SmallBusinessApp\admindb.mdb;"
strDestDB = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Development\SmallBusinessApp\temp.mdb;"

If Dir(strDestDB) <> &quot;&quot; Then Kill (strDestDB)
jroEngine.CompactDatabase strSourceDB, strDestDB & &quot;;Jet OLEDB:Engine Type=4&quot;

Kill (strSourceDB)
Name &quot;D:\Development\SmallBusinessApp\temp.mdb&quot; As &quot;admindb.mdb&quot;

Err_Handler:
If Err.Number <> 0 Then Debug.Print Err.Number, Err.Description

Is that may be a problem of the MDAC version. And how do I check that?
Thanks for any help.
 
Try this:

For Access 97, change:
Microsoft.Jet.OLEDB.4.0

to
Microsoft.Jet.OLEDB.3.51 Let me know if this helps
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
First of all, these lines are wrong and cannot work:

If Dir(strDestDB) <> &quot;&quot; Then Kill (strDestDB)
Kill (strSourceDB)

You are not using a path and file name here, but a connection string.

Which version of ADO are you using? (PROJECT|REFERENCES)
You should be using 2.5 or higher. If not, then change it.
If not available, then download the MDAC
Also, if you use MDAC 2.6/7 then download Jet 4.0 SP4
( or SP6 available at kb Q239114)

And, make sure you are also defining the Engine Type for the source as well in order to avoid mistakes.

johnwm suggestion should also work .....
[/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Thank you johnwm and CCLINT
Microsoft.Jet.OLEDB.4.0 works with Access97.

My code works now.
The problem was that the form contains an adodc control that opens a connection to the database at the Load event.
The database must be closed to compact.

Of course Kill(strSourceDB) was wrong.
Thanks again for your tips.
 

Um, That's not the error message that I get for error 2147467259.

The error message for this error number should state the the database cannot be opened because it is already opened by...


Therefore, we were mislead. [/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Yes, that's a problem I met frequently when working with ADO.
Quite often Error Number 2147467259 is raised but if there is an Error Description at all it is not always the same or it is not very helpful. Which doesn't make it easier to debug a program.

 
Resolved the problem finally:
The name &quot;admindb&quot; is already existing on Windows 2000. Well it was not very clever to use a database name with &quot;admin&quot; in it.
Thanks again for your tips.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top