Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All!
This time, im consulting about database connections.
Lets suppose that i have an application that use some odbc or oledb connection to a database and i run the refresh of this application on a bat file.
Sometimes, some refresh freeze on the load in the connection time. So, sometimes, the procces remains paused because the connection was not successfull.
The problem its that, i cannot permit that those procces keeps stopped because other procces must run.
So, the question is, theres any way to check if some procces have some connection problem and stop it?
Thanks for all!
Germán
Hi Germán,
maybe you can look for vendor specific time out parameters in the ODBC/OLEDB dialog to shorten the freeze time and then catch the script error:
set ErrorMode=0;
CONNECT ...;
if ScriptError > 1 then
//no connect, do something else...
end if
set ErrorMode=1;
- Ralf
Hi Ralf
Thanks for your answer but the problem is in the coonection line.
When you cannot connect, the script doesnt go on. So, i cannot enter into the If clausule to check if error...
There`s any workaround like timeout or something?
Thanks!!!
Which database vendor and which ODBC driver you're using?
In fact its an ODBC connection to a Visual FoxPro file. (a dbf file)
I Know... its old... but... theres some systems that still hav e this kind of information sources...
Thanks
MS says VFPODBC driver is no longer supported, you should use OLE DB:
http://msdn.microsoft.com/de-de/vfoxpro/bb190233.aspx
Btw. can you send me a VFP test file to do some research on this?
- Ralf
I did an example with OLE DB on a local Visual FoxPro file. It gets no error on the Connect if the file is not there (can not connected) but if you make a select. This can be catched as followed:
// connect
OLEDB CONNECT32 TO [Provider=VFPOLEDB.1;Data Source=C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO OLE DB PROVIDER\SAMPLES\NORTHWIND;Mode=Share Deny None;Extended Properties="";User ID="";Mask Password=False;Cache Authentication=False;Encrypt Password=False;Collating Sequence=MACHINE;DSN="";DELETED=True;CODEPAGE=1252;MVCOUNT=16384;ENGINEBEHAVIOR=90;TABLEVALIDATE=3;REFRESH=5;VARCHARMAPPING=False;ANSI=True;REPROCESS=5];
set ErrorMode=0;
// select
customers:
SQL SELECT *
FROM customers;
// error handling if not connected
if IsNull(NoOfRows('customers')) then
trace not connected;
exit script;
end if
// else further script execution
set ErrorMode=1;
- Ralf
the cut into the connection its in the oledb string, or not?
Thats why you dont get stoped?
What you mean with "the cut into the connection"?
At least the folder of the Data Source must exist. If it not exist the OLE DB Provider will open a dialog.
- Ralf
I undertud.
The problem its that when the connection call its launched, sometimes doesnt return any feedback.
The folder exist, the file exist, but the connection doesnt returns anything...
Thats why i need to stop the procces if the connection its freeze...
Thanks