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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing database name 1

Status
Not open for further replies.

MustangPriMe

IS-IT--Management
Oct 9, 2002
74
0
0
GB
I'm sure this must be a simple one, but it's eluded me so far.

How can I reference the name of the SQL database I'm connected to through VB in an Access ADP?

I have a live and development versions of my database, and I need the code to do slightly different things depending on which one I'm connected to.

Rather than changing a boolean flag in the code to say whether this is the `live` release or not, I'd like it to automatically detect based upon the db name.

Thanks
 
Thanks, but is there a property containing only the name of the database?
The connection string will obviously need processing to extract the db name.
 
Iterate through the connection properties to find the property name and then reference by name.

Dim pp As ADODB.Property
For Each pp In CurrentProject.Connection.Properties
Debug.Print pp.Name
Debug.Print "----------- "; pp.Value
Next '- end for loop
Debug.Print "catalog = "; CurrentProject.Connection.Properties("Initial Catalog")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top