Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Multiple Connection Strings in one QVS file

Hi,

I have multiple connection strings that are being used. Can I create QVS file with all the connection strings in that one single file? If yes, how?

1 Solution

Accepted Solutions
syukyo_zhu
Creator III
Creator III

Hi,

Yes you can

in your qvs, your define these connexions

v_DB_SALESFORCE

= 'CUSTOM CONNECT TO     ';

v_DB_Oracle ='                    ';

//Then in your application Qvw

//you can call your conexion like this

$(v_DB_SALESFORCE);

//At the end of your connexion

DISCONNECT;

//then you can an other connexion

$(v_DB_Oracle);

DISCONNECT;

View solution in original post

7 Replies
Anonymous
Not applicable
Author

you can use as many Connection strings as you like

But: you must extract the data from each database you want to connect to before the next Connection string

occurs

connect to ...

select * from tablea

select * from tableb

connect to ...

select *from tablec

select * from tabled

other possibility: if you want only 1 qvs with only Connection strings you may work with variables and use a Sub

Sub connect (DBA)

if (DBA=1, connect to ..)

if (DBA)2, connect to ...)

in your main script you call the Sub and then extract the data

call connect(1)

select * from tablea

does this helps you?

Anonymous
Not applicable
Author

If i have only one connection String, I can do it as :

SCRIPT:

$(Must_Include=$(Config)\ConnectionString.qvs) ;

TableA:

LOAD

....

...

And in the ConnectionString.qvs file, define the Connection String.

How will I do it if I have multiple connection strings and I want all those connection strings to be stored in a single .qvs file instead of one qvs file for each connection string?

santiago_respane
Specialist
Specialist

Hi,

you can have as many connection strings as you like, i use something like this:

  • In your QVS:

//First conn

set v.DBConnString1='Provider=OraOLEDB.Oracle.1;Persist Security Info=True;User ID=myUser;Data Source=mySource1;UseSessionFormat = 1;Extended Properties=""';

set v.DBConnString1Pass='RVEePSJMDSDFSDFDdeFRFNJE';

//second conn

set v.DBConnString2='Provider=OraOLEDB.Oracle.1;Persist Security Info=True;User ID=myUser;Data Source=mySource2;UseSessionFormat = 1;Extended Properties=""';

set v.DBConnString2Pass='RVEePRTSDFGSDF3453NJE';

  • And in your app:

//Connect to first db

OLEDB CONNECT TO [$(v.DBConnString1)] (XPassword is $(v.DBConnString1Pass));

//Do some stuff

DISCONNECT;

//Connect to second db

OLEDB CONNECT TO [$(v.DBConnString2)] (XPassword is $(v.DBConnString2Pass));

//Do some stuff;

DISCONNECT;

Let me know if this helps.

Kind regards,

Anonymous
Not applicable
Author

I would use my second choice:

you define your Connection strings in a single qvs by defining a Sub

Sub connect(DBA)

if (DBA=1, connect to Database1)

if (DBA=2, connect to Database2

end Sub

you call the include like you wrote

$(Must_Include=$(Config)\ConnectionString.qvs) ;

But before extracting data you define the datasource using a parameter

CALL CONNECT(1)

TableA:

load

..

does this clarifys your question?

syukyo_zhu
Creator III
Creator III

Hi,

Yes you can

in your qvs, your define these connexions

v_DB_SALESFORCE

= 'CUSTOM CONNECT TO     ';

v_DB_Oracle ='                    ';

//Then in your application Qvw

//you can call your conexion like this

$(v_DB_SALESFORCE);

//At the end of your connexion

DISCONNECT;

//then you can an other connexion

$(v_DB_Oracle);

DISCONNECT;

Anonymous
Not applicable
Author

I will try one and if it doesn't work, will switch to the next one. Will let you know guys. Thanks

Anonymous
Not applicable
Author

The one provided by xia worked. I had issues with Santiago's solution. Anyway, thanks guys