3 Replies Latest reply: Oct 25, 2011 11:48 AM by coolmanNL RSS

    pass a variable into connectstring with [ ...]

      Hi fellow qlikies.

       

      My first post to the community! Hope you can help.

      I want to pass a variable into my connectstring to be able to change the database name. Read some examples on the forum but none of them explain how to do this when you work inside the square brackets.

       

          CONNECT TO [    Provider=SQLOLEDB.1;

                          Persist Security Info=True;

                          User ID=Sa;

                          Initial Catalog=DB_LIVE;

                          Data Source=server1;

                          Use Procedure for Prepare=1;

                          Auto Translate=True;

                          Packet Size=4096;

                          Workstation ID=ICT0231;

                          Use Encryption for Data=False;

                          Tag with column collation when possible=False] (XPassword is SCRAMBLED);

       

      The above statement works fine. However setting ans inserting the variable won't work for me

       

      SET DbName='DB_LIVE';

       

       

      CONNECT TO [    Provider=SQLOLEDB.1;

                          Persist Security Info=True;

                          User ID=Sa;

                          Initial Catalog=DbName$;

                          Data Source=server1;

                          Use Procedure for Prepare=1;

                          Auto Translate=True;

                          Packet Size=4096;

                          Workstation ID=ICT0231;

                          Use Encryption for Data=False;

                          Tag with column collation when possible=False] (XPassword is SCRAMBLED);

       

      What's wrong ??