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.