Determining data source

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In our MS Access application, I've established 2 environments; production and
test. Other than the data source, they are (almost) identical. Is there a
way to programmatically check the data source, i.e., which SQL server that I
am connected to?

I would like to make a form control visible/invisible depending on data
source. The control would say something like, "Test Environment" if I'm
connected to my local SQL server. And say nothing (and be invisible) if I'm
connected to the production server.

tia,
 
Hi.
Is there a
way to programmatically check the data source, i.e., which SQL server that I
am connected to?

Depending upon the driver used to connect the front end to the back end,
check either the "Data Source" property or the "Server" property of the
ConnectionString property of the Connection object. Or, if you are using
DAO, then check the DSN of the Connect property of the TableDef object.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. (Only "Answers" have green
check-marks.) Remember that the best answers are often given to those who
have a history of rewarding the contributors who have taken the time to
answer questions correctly.
 
thanks for the quick reply.

What you said makes sense to me, and it helps. But I haven't the foggiest
how to go about checking those properties.

?
JMorrell
 
Hi.
But I haven't the foggiest
how to go about checking those properties.

That's okay. I haven't got the foggiest which method you're using to
connect to the back end, so we're even! Are you using linked tables, a DSN,
a DSN-less connection, or a connection string from a query? If it's a DSN or
DSN-less connection, are you using ADO or DAO? If you can answer these
questions and find the connection strings your database is using for both the
production and local servers (and post these strings into your next reply), I
can tailor a better answer for you.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. (Only "Answers" have green
check-marks.) Remember that the best answers are often given to those who
have a history of rewarding the contributors who have taken the time to
answer questions correctly.
 
Hi.
Linked tables; DSN connection; ADO

Excellent! And the connection strings for each of the SQL Servers? Without
them I'll have to give you an example that works on my computer, which isn't
connected to a SQL Server. MDB and the Jet driver is what you'll see in my
example, unless I see your connection string (but change any user ID and
password and the name of the server or DSN used in your connection strings,
because this is a public forum and anyone can see this).

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. (Only "Answers" have green
check-marks.) Remember that the best answers are often given to those who
have a history of rewarding the contributors who have taken the time to
answer questions correctly.
 
Thanks for your patience with me on this. I'm not so sure about the exact
connection string to my sql server because I make an odbc connection with the
ODBC Data Source Administrator. -- I do make a connection to the sql server
in one of my routines though. That one is:

strConn = "Provider='SQLOLEDB';Data Source='my_box';" & _
"Initial Catalog='my_db';Integrated Security='SSPI';"

thanks again,
JMorrell
 
Back
Top