Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
pnn44794
Partner - Specialist
Partner - Specialist

Garbage After Statement - Using Text File For Connection String

Hello:

Since I have multiple dashboards all using the same ID, it makes sense to me to create a text file with the connection string in it, with the ID, password, database, etc and then call that file from each dashboard using an include statement.  I'm currently testing it with just one dashboard and I'm getting the "Garbage after statement error".  A window pops up with that error message and once I click OK, the load script executes and I get connected to the database.  However, once the dashboard goes live, it will be run as a task via QMC.  Thus it will fail as you can't click OK.  Here's what is stored in the text file (note some values have been changed since they shouldn't be public, i.e. Source, Catalog, Password, etc):

Let vConnectionString='{OLEDB CONNECT TO [Provider=SQLOLEDB.1;Persist Security Info=True;User ID=USER1234;Initial Catalog=info;Data Source=my.database.server\SESSION;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=CHCAR10C38N1;Use Encryption for Data=False;Tag with column collation when possible=False] (XPassword is NotARealPassword)}';

Here is what I have in my load script on the Main tab.  There are then other tabs that get executed.  As a side note, I previously had the connection string in the load script and it ran fine.

$(Include=..\Config\DevSourcesI680656.txt);
CONNECT TO [$(vConnectionString)]
;

As always, any and all help is appreciated.  Thanks in advance.

1 Solution

Accepted Solutions
awhitfield
Partner - Champion
Partner - Champion

Hi Perry,

just had a play, Just put the actual connection string in your .txt

e.g. my file is connect.txt

OLEDB CONNECT TO [Provider=SQLOLEDB.1;Password=bpi;Persist Security Info=True;User ID=bpi;Initial Catalog=NHS_SLR;Data Source=(local);Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=CSD005779-DW7;Use Encryption for Data=False;Tag with column collation when possible=False]

then the includes statement using the insert includes statement:

$(Include=connect.txt);

and that's it.

save and reload

HTH

Andy

View solution in original post

2 Replies
awhitfield
Partner - Champion
Partner - Champion

Hi Perry,

just had a play, Just put the actual connection string in your .txt

e.g. my file is connect.txt

OLEDB CONNECT TO [Provider=SQLOLEDB.1;Password=bpi;Persist Security Info=True;User ID=bpi;Initial Catalog=NHS_SLR;Data Source=(local);Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=CSD005779-DW7;Use Encryption for Data=False;Tag with column collation when possible=False]

then the includes statement using the insert includes statement:

$(Include=connect.txt);

and that's it.

save and reload

HTH

Andy

pnn44794
Partner - Specialist
Partner - Specialist
Author

That worked.  Thank you very much Andrew.  The code I was using was from another thread related to using a text file to store your connection string and they used "CONNECT TO" as I had above.  Removed that and I was good to go.  Thanks again.