Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I used include file for connection strings.
But my question is, I have different connection strings of different environments, how do I call them intelligently?
correct
place each include file in each environment - since they ahve the same name, there are no coding changes required this way when moving from one environment to another
May be like:
If computername()= 'Machine1' Then
....this connection string
ElseIf Computername() = 'Machine2' Then
...that connection string
...
Endif
EndIf
Another example:
If WildMatch(vEnv, 'DEV') Then
OLEDB CONNECT TO [Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=*****; Data Source=****\****_DEV];
ElseIf WildMatch(vEnv, 'UAT') Then
OLEDB CONNECT TO [Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=*******; Data Source=****\****_UAT];
ElseIf WildMatch(vEnv, 'PROD') Then
OLEDB CONNECT TO [Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=*****; Data Source=*****\****_LIVE];
End If
Hi jonathan,
But how do you assign value for vEnv?
The way I have done in this in the past is each include file contains the connection string for the environment you are in. When the qvw is moved to a different environment, the include file in that environment would have a different string.
example - you have an include file called connection.qvs. The file contains the connection string - you would have 2 versions of this file - one in test, one in production.
When your qvw is in dev, when it includes the file in that environment, it contains the connection string for dev, when it runs in prodction, the connection string is in production.
This does make the assumption that your environments and folder structures are the same across environments
Hi Adam,
Am confused, if I have 2 environments, are you telling to use 2 different files?
basically yes - the file has the exact same name in both environments, the connection string is different - when the file gets included, it will use the one based in the environment you are in containing the appropriate string
Which means, You are changing the connection string based on the environment manually?
no the connection string is in the include file. Each include file, which has the same physical name has a differnt connection string. When you load the application and it includes the file, it will read in the file based on the environment you are in, there bringing in the connection string from that file
Oh I got it. So you create 2 files with same name but different connection strings.
It would pick up which ever it connects?