Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
Using VBScript I managed QV to reload data automatically on document opening. However, SQL server, where data resides, is not always available. How can I check availability before reloading or to interrupt the script with MsgBox("Server is not available", OK), without hanging up?
Thanks!
Try playing with ErrorMode variable:
// Some logic you may have here
SET ErrorMode = 0;
Do your ODBC/OLEDB connection
Do your Selection
if ScriptError > 1 then
// Error handler
SET ErroreMode = 1;
exit script;
end if
SET ErroreMode = 1;
// Further processing
Possible ScriptError values and it's description
1 No error
2 General Error
3 Syntax Error
4 General ODBC Error
5 General OLE DB Error
6 General XML Error
7 General HTML Error
8 File Not Found
9 Database Not Found
10 Table Not Found
11 Field Not Found
12 File Has Wrong Format
Hope this helps you.
Try playing with ErrorMode variable:
// Some logic you may have here
SET ErrorMode = 0;
Do your ODBC/OLEDB connection
Do your Selection
if ScriptError > 1 then
// Error handler
SET ErroreMode = 1;
exit script;
end if
SET ErroreMode = 1;
// Further processing
Possible ScriptError values and it's description
1 No error
2 General Error
3 Syntax Error
4 General ODBC Error
5 General OLE DB Error
6 General XML Error
7 General HTML Error
8 File Not Found
9 Database Not Found
10 Table Not Found
11 Field Not Found
12 File Has Wrong Format
Hope this helps you.
Rakesh,
Thank You so much!
Here is a look of my script (beta version 🙂 )
Set some_local_variables;
Set ErrorMode = 0;
ODBC CONNECT TO Database;
SQL SELECT Some, Fields FROM Table1;
STORE Table1 INTO Table1.qvd;
DROP Table1;
//The same with other tables.
Set ErrorMode = 1;
LOAD all_tables FROM qvd_files;
This way I have data loaded from last successful connection with data server. At this time, I have two questions:
1. There is a timeout (45 sec.) at the beginning of the script. To reduce it, I could run "PING DataServer_IP_address" into VBScript and exit script if no answer, but I can't find the syntax of command;
2. Please suggest me a manual where I can read for this!
Thank You again!
For your "ping" requirement, see enclosed app.
You can have this on "Open Document" trigger and based on the return variable value, you can continue with the script or not. I am sure some adjustments will be needed, but this will give you some ideas.
"Wow!" and some pings was in my head when I saw your code 🙂 I need some time to discover what happens. Thank you again!