Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Daniel Hofford
  Where is Daniel Hofford?
 Ocala
 Florida - United States
 Daniel Hofford
 To: Borislav Borissov
  Where is Borislav Borissov?
 Sofia
 Bulgaria
 Borislav Borissov
 Tags
Subject: RE: VPN Recovery
Thread ID: 143086 Message ID: 143109 # Views: 2 # Ratings: 0
Version: Visual FoxPro 9 Category: Network and Computer Management
Date: Friday, August 24, 2007 10:46:28 PM         
   


> > I should be more explicit. I don't mean recover the data. That won't be lost since its in a dbf on the remote machine that is trying to send it to the central server and only after the record is sent is it marked as being sent. What I meant by recover is that I'm in the middle of a code block transmitting data and I lose the connection it seems to me the whole program will just hang. I'd like to be able to return out of that code block and let the people at the remote site continue to work. The data that needs to be transmitted is being gathered all the time in a table and can be transmitted anytime. Once the connection is lost and data is added to the table that function that transmits gets called but if the connection isn't there it doesn't fire and just passes back and waits until someone adds another records that meets the criteria for being sent. So its only how to keep the program going in case the wire goes down during transmission. Any ideas?
> >
> >
> > Dan
> > "Our gold does not chink and glitter. It gleams in the sun and neighs in the dark." Chief Joseph
>
>
> SELECT timeinput
> WAIT WINDOW "Transmitting data..." NOWAIT
> CLEAR
> ?TIME()
> TEXT TO lcSQLStr NOSHOW PRETEXT 15
>       Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=N:\FOXPRO\DH\DH_RTDC;Exclusive=No;
>       Collate=Machine;NULL=NO;DELETED=YES;BACKGROUNDFETCH=NO
> ENDTEXT
> 
> TEXT TO lcTestConnection NOSHOW
>      SELECT TOP 1 (a field in the table) FROM SomeVPNTable WHERE (make the query optimizable)
> ENDTEXT
> 
> lnHandle = SQLSTRINGCONNECT(lcSQLStr)
> IF lnHandle > 0
>    =SQLSETPROP(lnHandle, 'asynchronous', .F.)
>    TEXT TO lcSQL TEXTMERGE NOSHOW PRETEXT 15
>         INSERT INTO vpntest(wo,lunch,
>                             t_in,
>                             t_out,
>                             route,
>                             empid,
>                             sysdate1,
>                             sysdate2,
>                             completed,
>                             qtybuilt,
>                             qty2bld,
>                             t_time,
>                             acctime,
>                             addtime,
>                             newfld) VALUES
>                            (?ab,
>                            ?bc,
>                             ?cd,
>                             ?de,
>                             ?ef,
>                             ?fg,
>                             ?gh,
>                             ?hi,
>                             ?ij,
>                             ?jk,
>                             ?kl,
>                             ?lm,
>                             ?mn,
>                             ?no,
>                             ?op)
>    ENDTEXT
>    =SQLPREPARE(lnHandle,lcSql)
> 
>    SET FILTER TO NOT Sent
>    SCAN
>         ab = wo
>         bc = lunch  &&L
>         CD = IIF(!EMPTY(t_in),t_in,.NULL.) &&DT
>         de = IIF(!EMPTY(t_out),t_out,.NULL.)   &&DT
>         ef = ALLTRIM(route)
>         fg = empid  &&C
>         gh = IIF(!EMPTY(sysdate1),sysdate1,.NULL.) &&DT
>         hi = IIF(!EMPTY(sysdate2),sysdate2,.NULL.) &&DT
>         ij = COMPLETED  &&L
>         jk = qtybuilt  &&N
>         kl = qty2bld  &&N
>         lm = t_time  &&N
>         mn = acctime &&N
>         no = addtime &&N
>         op = newfld &&C
>         IF SQLEXEC(lnHandle,lcSql) < 0
>            lcErrorMsg = "SQL failure ON INSERT vpntest."
>            AERROR( laError )
>            IF SQLEXEC(lnHandle,lcTestConnection) < 0
>               IF MessageBox([Connection is lost. Please reestablish the connection and click "Yes" to continue.].;
>                             4+48,[Lost connection]) == 6
>                  SKIP -1
>                  LOOP
>               ELSE
>                  EXIT
>               ENDIF
>            ELSE
>               =MESSAGEBOX("Something went wrong here"+CHR(13)+;
>                           (lcErrorMsg)+CHR(13);
>                           +"Error #: "+ALLTRIM(STR(laError(1)))+CHR(13);
>                           +"Error Message: "+ALLTRIM(laError(2)),16,"Error Message")
>              EXIT
>           ENDIF
>        ELSE
>           replace sent WITH .t.
>        ENDIF
>    ENDSCAN
>    = SQLDISCONNECT(lnHandle)
>    WAIT WINDOW NOWAIT "Data Transmitted! Hmm, may be"
> ELSE
>    lcErrorMsg = "Could not connect to VPN Server."
>    AERROR( laError )
>    =MESSAGEBOX("Something went wrong here"+CHR(13)+;
>               (lcErrorMsg)+CHR(13);
>               +"Error #: "+ALLTRIM(STR(laError(1)))+CHR(13);
>               +"Error Message: "+ALLTRIM(laError(2)),16,"Error Message")
> ENDIF
> 

> This is very rough code. I wrote it directly here w/o any testing just to give you an idea.
> (I stole it from Andy Kramek :o)
> When your insert fails for some reasons, immediately call a command that you are sure it must returns some vaules (no matter what). If that command fails that means you lose the connection.
>
>
> -----------------
> Borislav Borissov
>
> Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
> The only thing normal about database guys is their tables.

Thanks for that! I take it there's no handshaking available in VFP without access to C routines addressing the API which are probably too difficult to even contemplate.

Do you have any knowledge of how to set up VFPServer. I have both ends of it and all the documentation in Spanish! :)

Dan
"Our gold does not chink and glitter. It gleams in the sun and neighs in the dark." Chief Joseph

ENTIRE THREAD

VPN Recovery Posted by Daniel Hofford @ 8/24/2007 6:54:24 PM
RE: VPN Recovery Posted by Ken Murphy @ 8/24/2007 7:04:20 PM
RE: VPN Recovery Posted by Daniel Hofford @ 8/24/2007 9:07:57 PM
RE: VPN Recovery Posted by Ken Murphy @ 8/25/2007 1:56:00 AM
RE: VPN Recovery Posted by Daniel Hofford @ 8/25/2007 3:03:33 AM
RE: VPN Recovery Posted by Ken Murphy @ 8/25/2007 2:27:47 PM
RE: VPN Recovery Posted by Eric den Doop @ 8/24/2007 9:02:07 PM
RE: VPN Recovery Posted by Daniel Hofford @ 8/24/2007 9:09:55 PM
RE: VPN Recovery Posted by Borislav Borissov @ 8/24/2007 9:28:00 PM
RE: VPN Recovery Posted by Daniel Hofford @ 8/24/2007 9:44:41 PM
RE: VPN Recovery Posted by Borislav Borissov @ 8/24/2007 9:49:56 PM
RE: VPN Recovery Posted by Daniel Hofford @ 8/24/2007 9:56:24 PM
RE: VPN Recovery Posted by Borislav Borissov @ 8/24/2007 10:41:07 PM
RE: VPN Recovery Posted by Daniel Hofford @ 8/24/2007 10:46:28 PM
RE: VPN Recovery Posted by Borislav Borissov @ 8/24/2007 10:48:32 PM
RE: VPN Recovery Posted by tushar @ 8/25/2007 8:57:40 AM
RE: VPN Recovery Posted by Eric den Doop @ 8/25/2007 10:08:19 AM
RE: VPN Recovery Posted by Daniel Hofford @ 8/26/2007 2:11:00 AM
RE: VPN Recovery Posted by Eric den Doop @ 8/26/2007 9:30:23 AM
RE: VPN Recovery Posted by Daniel Hofford @ 8/26/2007 3:54:40 PM
RE: VPN Recovery Posted by Eric den Doop @ 8/26/2007 9:13:50 PM
RE: VPN Recovery Posted by Daniel Hofford @ 8/27/2007 12:26:18 AM
RE: VPN Recovery Posted by Daniel Hofford @ 8/26/2007 2:10:21 AM
RE: VPN Recovery Posted by tushar @ 8/26/2007 8:13:46 AM
RE: VPN Recovery Posted by Daniel Hofford @ 8/26/2007 3:57:07 PM
RE: VPN Recovery Posted by tushar @ 8/26/2007 4:27:33 PM