Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I'm working on a program that uses an Access db on the back end... I need to have database compacting available. I'm using the COM object JRO (Jet Replication Objects...replacement to the old DAO). This object has the CompactDatabase method, slightly differant from the old DAO method, but same thing... anyhow this is what I got:

 

string SRC_DB = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Database Password=" + @Password + ";Data Source=" + @sourcePath + ";";
		string DST_DB ="Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Database Password=" + @Password + ";Data Source=" + @destPath + ";";
		try
		{
			JRO_JEC.CompactDatabase(SRC_DB, DST_DB + ".mdb");
		}
		catch (System.Exception ex)
		{
			Console.WriteLine("Failed! Error:{0}", ex.Message);
		}

 

Now if I take the password off the database and drop the UserID and Database Password portion it works, but the db needs a password, so thus the extra parameters. These parameters work perfectly when connecting to the db using ADO.NET, but with this method (OR THE OLD DAO CompactDatabase Method) I get "Could not find installable ISAM".... any ideas? Or do you know a better way to compact? FYI.... using the full connection string (all the parameters) results in the 'Incorrect Parameter Format' error... and again, the same thing (copy and pasted) in ADO.NET works fine)... also using the old fashioned Password=password results in the 'Workgroup file missing or locked exclusively by another user'... this is a simple fix, I just can't seem to figure out what the problem is... what works in an ADO.NET connection string should work here too!

Edited by bri189a
Posted

Found the problem... like I said... something stupid (happens when you only have 3 hours of sleep)... the code works fine... I just can't append ".mdb" at the end of the connection string! Duh! It's suppose to be at the end of the file name.... what an idiot I am! :(

 

Sam - actually I haven't seen an ADO.NET method for compacting... if there is one let me know!~ Thanks!

Posted

I'm pretty sure. I know for an previous app we had we just distributed this Excel object that gave us access to all of excels methods so that we could export the data into a spreadsheet. The client machine still counted as having Office of course for licensing purposes.

 

But if the backend has an access database, then I assume it also has access, and therefore this shouldn't even be a problem.

Posted

Sam, so you know, the Access object uses the DAO object to compact database in Office 97 and prior:

 

DAO.DatabaseEngine.CompactDatabase(sting, string, object, long (flag));

 

Office 2000 will still use the DAO method but Microsoft recommends uses JRO (Jet Remotable? Object), and this is the method for Office 2002, and 2003 as I understand... don't have those versions yet:

 

JRO.JetEngine.CompactDatabase(string, string);

 

So in reality, using Access.Application() I would still have to go back and use either DAO or JRO to do the compacting... because that's how Access does it internally.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...