Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Announcing the newest addition to the Qlik Community, Qlik Gallery! Learn More
Highlighted
Not applicable

Switching SQL Connection String with external file

Hi all,

I try to setup my QlikView script to switch between two OLEDB Connection Strings via a external file.

Storing my Connection Strings in two different qvs files (CONNECTION_SQL_TEST.qvs and CONNECTION_SQL_PROD.qvs)

Loading the file text file that contains the Instance Name (TEST or PROD) and write a variable called vSQL_INSTANCE. In this variable it will be simply stored 'TEST' or 'PROD'

Tried to create a condition like this:

if($(vSQL_INSTANCE)='TEST'
,
$(Include=$(path_toggel)CONNECTION_SQL_TEST.qvs);
,
$(Include=$(path_toggel)CONNECTION_SQL_PROD.qvs);
)

Result -> Syntax Error.


Could anymody help me with that?

Is it actualy possible to use a if condition in combination with Connection Strings?

Thank you for your efforts.

Kind Regrads

Philipp

1 Solution

Accepted Solutions
MVP
MVP

Re: Switching SQL Connection String with external file

Dont try to do it in an expression. Use this:

If vSQL_INSTANCE = 'TEST' Then

  $(Include=$(path_toggel)CONNECTION_SQL_TEST.qvs);

Else

  $(Include=$(path_toggel)CONNECTION_SQL_PROD.qvs);

End If

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
6 Replies
Not applicable

Re: Switching SQL Connection String with external file

if($(vSQL_INSTANCE)='TEST'
,
$(Include=$(path_toggel)CONNECTION_SQL_TEST.qvs)
,
$(Include=$(path_toggel)CONNECTION_SQL_PROD.qvs)
);

Not applicable

Re: Switching SQL Connection String with external file

Hi Rodrigo,

thank you for answering, but this is also not working "Script Error - Unknown statement" ...

I think the Syntax is still wrong, or maybe it is not possible to combine if withOLEDB CONNECT TO ??

Kind regards

Philipp

MVP
MVP

Re: Switching SQL Connection String with external file

Dont try to do it in an expression. Use this:

If vSQL_INSTANCE = 'TEST' Then

  $(Include=$(path_toggel)CONNECTION_SQL_TEST.qvs);

Else

  $(Include=$(path_toggel)CONNECTION_SQL_PROD.qvs);

End If

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
MVP
MVP

Re: Switching SQL Connection String with external file

Or you could try this:

$(Include=$(path_toggel)CONNECTION_SQL_$(vSQL_INSTANCE).qvs);


(BTW -  I would use $(must_include=...) for a connection string so that the script fails at the right place if the include file cannot be found)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable

Re: Switching SQL Connection String with external file

Thank you so much.

This solved my problem.

Kind regards

Philipp

Not applicable

Re: Switching SQL Connection String with external file

Good idea!! 🙂

That was not my intention, but works anyway.

Thank you 🙂