Change programmatically server properties

  • Thread starter Thread starter Atlas
  • Start date Start date
A

Atlas

Is it possible to change the SQL server properties in my project at startup,
to switch from a test db to a production one?
Actually the server name, cause the database and the table names will be
thesame.....

Thanks
 
Atlas said:
Is it possible to change the SQL server properties in my project at startup,
to switch from a test db to a production one?
Actually the server name, cause the database and the table names will be
thesame.....

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

..MDB/E front-ends (Access 2000 & greater versions): Change the
connection string on each of your linked tables & SQL Pass-Thru queries.
E.g. (substitute your DB names for my example DB names):

dim db as dao.database
dim td as dao.tabledef
dim strConnect as string

set db = currentdb
set td = db.tabledef("TableName")
strConnect = td.Connect
strConnect = Replace(strConnect, "Database=TestDB", _
"Database=ProductionDB")
td.Connect = strConnect
td.RefreshLink

[basically the same for QueryDefs]

..ADP/E front-ends: Change the ProjectConnection string. E.g.:

dim strConnect as string
strConnect = CurrentProject.BaseConnectionString
strConnect = Replace(strConnect, "Catalog=TestDBName", _
"Catalog=ProductionDBName"
CurrentProject.OpenConnection(strConnect)

What it does: Gets the current connection string to the Test DB &
replaces the Catalog/Database name w/ the production DB name; then sets
the current project's connection to that new connection.

- --
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQGxa3oechKqOuFEgEQIRewCgg5Y8dyRzG8XQuFmWSEuewikX2TwAoO/3
IFV+JtVW1DJNgO5zjFb5oMrJ
=9r6+
-----END PGP SIGNATURE-----
 
MG, I only need to replace the server name, not the tables. As I've said the
DB and the tables will have the same names...I only need to switch the
SQLserver name.....

Thanks
 
Atlas said:
MG, I only need to replace the server name, not the tables. As I've said the
DB and the tables will have the same names...I only need to switch the
SQLserver name.....

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Yeah... I see that now. For some reason I fixated on changing the
database name. Here is the fixed code for server name:

== .mdb files - each tabledef connection string has to be changed ==

dim db as dao.database
dim td as dao.tabledef
dim strConnect as string

set db = currentdb
set td = db.tabledef("TableName")
strConnect = td.Connect
strConnect = Replace(strConnect, "Server=TestServer", _
"Server=ProductionServer")
td.Connect = strConnect
td.RefreshLink

[basically the same for QueryDefs]

------

== .ADP/E front-ends: Change the ProjectConnection string. ==

dim strConnect as string
strConnect = CurrentProject.BaseConnectionString
strConnect = Replace(strConnect, "Source=TestServer", _
"Source=ProductionServer"
CurrentProject.OpenConnection(strConnect)

- --
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQG4sN4echKqOuFEgEQLDjQCfY0Z+bKcEhGh0q67lbbm8PgE/YU8AoNBj
7Rv8DFS4UhTUzc7KGJxlmi1S
=plcR
-----END PGP SIGNATURE-----
 
Back
Top