Community
Showing results for 
Search instead for 
Do you mean 
Reply

Database ID

Tuned Listener
Posts: 23
Country: UK

Database ID

Does an Act database have a unique identifier? I thought there was an old topic on the subject but I can't see anything about it on the forums. Thanks Russell
Tuned Listener
Posts: 23
Country: UK

Re: Database ID

Bumpety Bump

Does anyone have any idea how to uniquely identify an ACT! database? By UID or otherwise?

Regards,

Russell
Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Database ID

Hi Russell,
 
Each ACT! dB in the SQL Server has to have a unique name, so you could use that as the unique identifier?
 
Vivek
Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
Tuned Listener
Posts: 23
Country: UK

Re: Database ID

Is that going to be unique if two people create a database of the same name?

Russell
Copper Contributor
Posts: 97
Country: USA

Re: Database ID

ACT! will not allow you to create two databases with the same name (on the same SQL Server instance).  If I try, I get the following:
 
    A database with the specified name already exists. Please specify a unique name.
 
So, you can uniquely identify an ACT! database by combining the machine name/SQL named-instance plus the database name:
    mymachine\act7\mydatabase
Or, from the user's (or .PAD file) perspective:
    host="mymachine" name="mydatabase"
 
HTH,
jason
Jason Sellers
ACT! Engineer 2000-2007
Tuned Listener
Posts: 23
Country: UK

Re: Database ID

brilliant, thank you

Regards

Russell
Copper Contributor
Posts: 14
Country: United States

Re: Database ID (and GUID)

[ Edited ]
For everyone who ends up at this topic unsatisfied... I don't like the idea of using a string comprised of machine name and database name. Either could change and I have other reasons as you will see.

After several hours digging through the ACT SDK Code Reference I finally found what would appear to be a genuine GUID for an ACT database. It apparently gets created only if a database is using Synchronization.  With that proviso, you will find it in the properties of the SynchronizationManager class. I am not sure if this object is available in all versions/flavors of ACT, but I am using it for now.

Like all ACT Managers, you fetch the SynchronizationManager via the ActApplication object:

SynchronizationManager syncMgr = myActApplicationObject.ActFramework.SynchronizationManager;

 


There are actually two GUID values available here: one for the Local database and one for the Publisher database (if the local database is a Synchronization Subscriber).  If you are not using Synchronization, I believe you will find both GUIDs to be all zeroes (therefore, of no use to non-Sync users).  Nonetheless:

// fetch the local database GUID (on my machine)
string localGUID = syncMgr.LocalDBGuid.ToString();

// fetch indicator as to whether current DB is a Subscriber
bool dbIsSubscriber = syncMgr.IsSubscriberDB;

// fetch the Publisher (master) database GUID
string masterGUID = syncMgr.PubDBGuid.ToString();

 


This was useful to me because I have some User Settings that are particular to the database schema. I wanted to segregate these User Settings by specific database in my User Settings file (e.g., "user.config").

I use the Publisher GUID, if there is one, to segregate and identify my database-specific User Settings. The Publisher database is the keeper of the database schema for itself and all Subscribers, so that is the GUID I use regardless of whether the user is accessing the central database (the Publisher) directly or accessing the remote database (Subscriber) on their laptop.  In other words, I fetch the Publisher GUID if the current open database is a Subscriber, otherwise I fetch the Local GUID.

Hope this helps another helpless soul like myself. I would appreciate hearing of any exceptions, caveats, problems, etc. related to these GUIDs.
Message Edited by steve.m on 01-29-2010 03:58 PM
Avid Listener
Posts: 44
Country: USA

Re: Database ID (and GUID)

Steve,

 

Thanks this code help me a lot when determining if the DB currently open is a remotedb or not.

 

Kudos

DBS