What i am trying is to access the MS Access properties without actually opening the database.
Here is some code to get a better understanding:
var processStartInfo = new ProcessStartInfo(args[0])
{
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true
};
Process.Start(processStartInfo);
application = (Access.Application)Marshal.GetActiveObject("Access.Application");
dao.Property allowByPassKeyProperty = null;
foreach (dao.Property property in application.CurrentDb().Properties)
{
if (property.Name == "AllowByPassKey")
{
allowByPassKeyProperty = property;
break;
}
}
My problem is that in that case, I open the database in order to look for the properties (application.CurrentDb().Properties) and the MS Access startup stuff kicks in.
I want to avoid all the startup stuff, and just inject the right value for the property.
Is it possible to go through the properties, maybe with reflection and late binding like that: http://www.codeproject.com/KB/database/mdbcompact_latebind.aspx?
Or is there any other option to achieve what I'd like?
Sorry I don't have details, but looking into using DAO to open the Access database(assuming it's pre-2007). DAO is the native access/jet code, so you don't have to actually start the entire Access application.
Sone old VB.Net (yes, .Net) code I have lying around:
m_oEngine = New DAO.DBEngine
m_oEngine.SystemDB = sWorkgroupFile
m_oWorkspace = m_oEngine.CreateWorkspace("My Workspace", sUserName, sPassword, DAO.WorkspaceTypeEnum.dbUseJet)
m_oDatabase = m_oWorkspace.OpenDatabase(sDatabaseFile, bExclusive, bReadOnly) ' Note DAO docs say the second parameter is for Exclusive