Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
kmswetha
Creator
Creator

Differenct connection strings

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?

1 Solution

Accepted Solutions
Not applicable

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

View solution in original post

12 Replies
tresesco
MVP
MVP

May be like:

If  computername()= 'Machine1'  Then

     ....this connection string

ElseIf Computername() = 'Machine2'  Then

     ...that connection string

     ...

Endif    

EndIf

jonathandienst
Partner - Champion III
Partner - Champion III

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

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
kmswetha
Creator
Creator
Author

Hi jonathan,

But how do you assign value for vEnv?

Not applicable

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

kmswetha
Creator
Creator
Author

Hi Adam,

Am confused, if I have 2 environments, are you telling to use 2 different files?

Not applicable

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

kmswetha
Creator
Creator
Author

Which means, You are changing the connection string based on the environment manually?

Not applicable

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

kmswetha
Creator
Creator
Author

Oh I got it. So you create 2 files with same name but different connection strings.

It would pick up which ever it connects?