Is there any way to check if an Access web database is online? I am connecting to the database via OleDB and the Microsoft.ACE.OLEDB.12.0 provider. The database contains local tables as well as some web tables. I need to be able to check if the web tables are connected to the SharePoint database. I am also using the Access Interop library to perform some actions – if I can use that to check if the database is online, that works too.
Share
The Access client knows if it is “on” line or “off line”. So there must be some way that Access tests/checks/knows that those tables are currently disconnected (local), or in fact have a live connection to SharePoint and is active syncing data. My spider sense tells me that this status might not be exposed and if it is, I not aware of how to grab that value.
However you can attempt to force a full web sync operation and if you are off line, then you will receive a trappable error (3021). This seems like somewhat of a kluge, and it entire possible that the status able to be checked (but I not aware how at this point in time).
So attempting a sync will force this issue.
eg
As a heads up, acCmdSyncWebApplicaiton constant is 699
However the above does in fact toss up a dialog box that has to be dismissed. So above is ok for user interaction button but NOT inter-op or automation without user interaction.
The only way I know how to do this right now from Access is to call a table level procedure on SharePoint.
The following works quite well for me:
If we are on line and tables connected, then calling the table level procedure (it does nothing) works just fine, and errnumber = 0. If we are off line, then calling the table procedure is not possible, and thus error number = 13087.
As noted since we are dealing with automatic connect or disconnedted tables, then my VBA code that opens up tables runs just fine regardless if you have a network connection or the application is running “off line” as opposed to “on line”. I don’t think that code knows or cares and that is much your problem.
So I am able call that table procedure from Access. I believe the docmd object and methods are exposed as a automation (interop) to .net, so at this point in time I am offing this kluge, and it does work quite well for me. If rundatamacro is exposed, then you can use this idea.
A another kluge (one that will likly work better for you) is to use a dumy table and add a new record. When tables are off line the autonumber PK value generated is negative values. When you are finally on line and sync, then those PK negative numbers are replaced by server side generated PK positive values.
And WHEN you are on line and add a row, you get a positive autonumber PK value. So another possible trick here is to simply have a dummy table with no records.
You then simply add a record, ensure it is saved. You then grab the pk value, and then I suppose just delete the row. (so the table never fills up). If the pk value is > 0, you are on line and connected. If the PK value is < 0, then you are in off line disconnected mode. So one “hint” or idea is in off line mode PK row values are going to be replaced when you finally do get a conneciton an sync, and during that off line time frame, those PK values are < 0.