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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
shree909
Partner - Specialist II
Partner - Specialist II

Connecting to database Dynamically

Hi Folks,

I  have 2 odbc connections one for production, Development.

The entire script remains same  only i need to change the odbc connection depending on the computername or servername

so i did like this but its not allowing me to do in the script and throwing an error.

if i want to use the if condition in the script  how to add??

 

IF(ComputerName()='ABC','ODBC CONNECT TO [xysbef;DBQ=xysbef] (XUserId is bJKfcYZODbXKXZVMSbXEXSFMETFA, XPassword is AJWSQYZODDZCGaFMRJIQL)',

if(computername()='DEF','ODBC CONNECT TO [yeyeye;DBQ=yeyeye ] (XUserId is KTDBaYZODbXKXZVMSbXEXSFMEbeB, XPassword is eNUWRYZODDZCGaFMRJIAG)'));

so when the computername is identified it should connect to that server odbc connection.

Thanks

1 Solution

Accepted Solutions
rbecher
MVP
MVP

Hi Shree,

just use the IF statement, not function:

IF ComputerName()='ABC' THEN

     ODBC CONNECT TO [xysbef;DBQ=xysbef] (XUserId is bJKfcYZODbXKXZVMSbXEXSFMETFA, XPassword is AJWSQYZODDZCGaFMRJIQL);

ELSEIF ComputerName()='DEF' THEN

     ODBC CONNECT TO [yeyeye;DBQ=yeyeye ] (XUserId is KTDBaYZODbXKXZVMSbXEXSFMEbeB, XPassword is eNUWRYZODDZCGaFMRJIAG)';

ELSE

     // error action

END IF

- Ralf

Astrato.io Head of R&D

View solution in original post

2 Replies
rbecher
MVP
MVP

Hi Shree,

just use the IF statement, not function:

IF ComputerName()='ABC' THEN

     ODBC CONNECT TO [xysbef;DBQ=xysbef] (XUserId is bJKfcYZODbXKXZVMSbXEXSFMETFA, XPassword is AJWSQYZODDZCGaFMRJIQL);

ELSEIF ComputerName()='DEF' THEN

     ODBC CONNECT TO [yeyeye;DBQ=yeyeye ] (XUserId is KTDBaYZODbXKXZVMSbXEXSFMEbeB, XPassword is eNUWRYZODDZCGaFMRJIAG)';

ELSE

     // error action

END IF

- Ralf

Astrato.io Head of R&D
shree909
Partner - Specialist II
Partner - Specialist II
Author

Hi  Ralf Becher,

That works perfect...

Thanks

Sree