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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need VB script advice - dynamically change the DBname and table name in the Edit script

Hi All,
I have one task. I have 3 different databases and all the database will have same table structure but the table name will be different. My database names will be like AView, DView and NView and tables like A_Analysis,D_Analysis and N_Analysis

I want to change the database name and table name dynamically and reload the report.
for /e.g/
I have created a report based on one database.


connection string:
CONNECT TO [Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DVIEW;Data Source=DB003;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=DB003;Use Encryption for Data=False;Tag with column collation when possible=False];

SQL:
SELECT * FROM D_Analysis;

I want to change the only the first two letters of the database name and the table name dynamically. In the list box, lists all the names like D,N,A etc.

select the A in the list box and click the button to change the connection string and the query and reload the document. Previously was DView after reloaded AView.

How can i do that. How can i pass the the value from list box to edit script? or is there any other option to perform this task?

After reloading the document it should point to the select database records.

Thanks,
Raghu

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Raghu,
You can use variable. Allow it to be A, or D, or N. The connect string will be
... Initial Catalog=$(Var)VIEW...
And, in SQL
.. FROM $(Var)_Analysis

View solution in original post

6 Replies
Anonymous
Not applicable
Author

Raghu,
You can use variable. Allow it to be A, or D, or N. The connect string will be
... Initial Catalog=$(Var)VIEW...
And, in SQL
.. FROM $(Var)_Analysis

Not applicable
Author

Micheal,

thanks, Let me try and get back to you if i find any problem

thanks

RAghu.

Not applicable
Author

I have got a solution. Now i can dynamically change the database name and table name in the edit script. I have to select, which database i want. Reload the document it will take records from the selected values from the database tables.

I have changed the edit script what Micheal suggested. Thanks again.

Thanks,

Raghu.

Not applicable
Author

Hi Raghu,

I'm new to QlikView and have similar situation like you had. Could you pls. send me the script .

Thanks,
Pratul.

Not applicable
Author

Hi Pratul,

Check the attached file. Hope this file gives you some input.

regards,

Raghu.

Not applicable
Author

Thanks a lot Raghu.