Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
viveksingh
Creator III
Creator III

variable in lib connection

Hi All,

I want to pass my variable which stored connection string. 

Below is what my code which is not working. 

let vuser='ABC';

let vDS='XYZ';

let VPass='12345';

SET VDEV ='OLEDB CONNECT TO [Provider=OraOLEDB.Oracle;User ID=$(vuser);Data Source=$(vDS);]  (XPassword=$(VPass))';

LIB CONNECT TO '$(VDEV)';

the above code is not working. please suggest 

 

Labels (2)
3 Replies
mikaelsc
Specialist
Specialist

data connections need to be created as (securable) ressources in the qmc. 

you could create several connections, and use their names in the variable VDEV. 

but once created, i don't think data source, username and pw are not editable entities of a connection. 

 

viveksingh
Creator III
Creator III
Author

Yes, I understand . But when I move from dev to prod, I have to change the connection string every time. if in case missed, all QVDs will have wrong data. So I'm planning to use variable in each environment so that when the data will be correct. 

Vegar
MVP
MVP

You need to define the connection in a LIB.

 

What about creating two LIBs? One for PROD and one for DEV. If your variable states  'PROD' then connect to the lib called MyDatabasePROD and if its 'DEV' then MyDatabaseDEV (LIB:\\MyDatabase$(yourVariable)\).

Or even simpler let the variable contain the name of your lib. LIB:\\$(yourVariable)\