Qlik Community

QlikView Documents

Documents for QlikView related information.

Connect to Database until success

MVP & Luminary
MVP & Luminary

Connect to Database until success

Hi,

I found that sometimes in my Dashboard it is failing to connect, so that again I have to manually reload the dashboard again and again until it Connects and Reloads, to overcome this I used below script.  Hope this helps others who are facing similar type of issues.

SET ErrorMode=0;

SET vIndex = 1 ;

DO

  ODBC CONNECT TO [PROD_DB;DBQ=PROD] (XUserId is dummyUser, XPassword is dummyPWD);

 

  IF Len(ConnectString()) = 0 THEN  // If Database is connected then ConnectString() will give you the active connection string otherwise                                                                  empty string is returned

       SET vIndex = 1; // If database is not connected then initialize variable to repeat the loop

  ELSE

       SET vIndex = 2; // If database is not connected then initialize variable to repeat the loop

  ENDIF

LOOP WHILE vIndex = 1;

SET ErrorMode=1;

Regards,

Jagan.

Comments
v_iyyappan
Valued Contributor

Its a nice post. I can use my app.

0 Likes
Not applicable

Hi guyz can I get Qlik view server i want to run  BI ON THE SERVER

0 Likes
vikasmahajan
Esteemed Contributor

Thanks for Sharing Jagan

0 Likes
Not applicable

Hi Jagan, I tried something similar and it works. However, when I run this in QMC, it doesnt reload again and again -fails the first time it encounters an error. Have you faced similar issues ?if yes, can you please share how you overcame it?

I realized that my script was missing SET ErrorMode=0; statement before odbc statement. Could this be the reason for failure in QMC?

0 Likes
MVP & Luminary
MVP & Luminary

The same code should work in server also.  Here the key is Set ErrorMode = 0; Change this and try;.

Regards,

Jagan.

0 Likes
Not applicable

Excuse me!

But so will use more server resources ?

0 Likes
MVP & Luminary
MVP & Luminary

No, it will try to connect once the first connection is failed.  If this is the requirement then we have to go for this.

0 Likes
Version history
Revision #:
1 of 1
Last update:
‎2014-08-22 03:14 AM
Updated by: