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

Dynamically Change DataSource

Hi,

I have a QVW file which is currently built against  the Development Server of Sql Server,And i have plenty of those.Is there anyway that  the DataSource inside the Connection String can be changed from Dev to prod while moving these QVD's into Prod environment rather than editing the script task each and every time and chaging the DataSource?

Thanks,

Sujith.

1 Solution

Accepted Solutions
danielrozental
Master II
Master II

Sorry Sujith, I made a mistake, you need to write the entire connection string into the text file.

View solution in original post

9 Replies
danielrozental
Master II
Master II

I believe the best practice for this is to use an external text file and include that file into your code.

That way you can just change the text file in production but you don't need to change the QVW everytime you move it to production.

danielrozental
Master II
Master II

Let's do this over here, it might help someone else.

Create a text file, call it config.txt

Write the following into the file

let vDATASOURCE = 'yourdevelopmentdatasource';

Then your QVW code will be

$(Include=config.txt)

OLEDB CONNECT TO [...;Data Source=$(vDATASOURCE);...]

Not applicable
Author

Hi Daniel,

Thanks for your reply,I created a txt file with the name of the server in it and inside the Datasource i gave the vDATASOURCE thing but when i hit a reload its asking me for the name of the server each and every time.Is there any way to get around it?I included the name of the server in my text file .

Thanks,

Sujith.

danielrozental
Master II
Master II

Is it asking for the server name or for the connection credentials?

Not applicable
Author

It is asking for the server name as well as the Login Credentials however if i just mention the server name and hit ok it takes it and reloads the script.

danielrozental
Master II
Master II

Does it work fine if you don't use the variable and just write the source name in the script? Or does it still ask you for the server name?

Not applicable
Author

Hi Daniel,

Let me be clear here I created a text file named servers.txt which has

let vDATASOURCE = 'JJLEDW1';

inside it.I also created a variable named 'vDATASOURCE' and set the Input Constraints to No Constraints and didnt give any value for the variable either.

Inside the script task ,I did something like this

$(Include=Servers.txt)

OLEDB CONNECT TO [.............Data Source=$(vDATASOURCE);........]

Now when i hit a reload its asking me for the server name?

Can you correct me if i went wrong somewhere?

Thanks,

Sujith.

danielrozental
Master II
Master II

Sorry Sujith, I made a mistake, you need to write the entire connection string into the text file.

Not applicable
Author

Hi Daniel,

thanks it worked i copied the whole connection string into a text file and used a incluse statement inside the script task to call the file.

Thanks.