Solved

Copy table as needed over the internet

Posted on 2011-09-15
6
457 Views
Last Modified: 2012-05-12
Hi experts,

I have an application that some users are running on the field. The application is a quote application. What I would like to acomplish is that when the application starts, it could check a table over the internet and if this table is newer that the one in the laptop it will replace it. The table is small table, it can even compressed and have it as a zip file.

Thanks,

0
Comment
Question by:falvarad
  • 3
  • 3
6 Comments
 
LVL 4

Expert Comment

by:wcsoctu
ID: 36545424
* in my opening prg (http://www.west-wind.com/wwipstuff.zip)
SET PROCEDURE TO wwUtils.prg
SET CLASSLIB TO wwIPStuff


* my internet function
FUNCTION Internet
DECLARE SHORT InternetGetConnectedState IN wininet.Dll;
   INTEGER @lpdwFlags, INTEGER dwReserved
LOCAL lConnected
lConnected = .F.
lpdwFlags = 0
IF InternetGetConnectedState (@lpdwFlags, 0) = 1
   MyFTP=CREATE('wwFTP')
   ConnectResult=MyFTP.FTPConnect('myftpsite',"myftpuser","myftppassword")
   FTPFound=(ConnectResult=0)
   lConnected = .T.
ENDIF
RETURN lConnected


* my code to check for update

IF Internet()
   * get remote file details, if not there no need to go further
   RemoteFileFound=.F.
   DIMENSION RemoteArray(1,4)
   ADIRResult=MyFTP.aFTPDIR(@RemoteArray,"ftpfolder/ftpfile.dbf")
   IF ADIRResult>0
      RemoteFileFound=.T.
      RemoteFileSize=RemoteArray(1,2)
      RemoteFileDate=TTOD(RemoteArray(1,4))
   ENDIF

   IF RemoteFileFound
      UpdateTheFile=.F.
      CompareCount=ADIR(LocalArray,'c:\localfolder\localfile.dbf')
      IF CompareCount=1
         LocalFileSize=LocalArray(1,2)
         LocalFileDate=LocalArray(1,3)
         IF RemoteFileSize<>LocalFileSize OR RemoteFileDate>LocalFileDate
            UpdateTheFile=.T.
         ENDIF
   ELSE
      UpdateTheFile=.T.
   ENDIF
   IF UpdateTheFile
      MyFTP.FTPGetFileEx("ftpfolder/ftpfile.dbf","c:\localfolder\localfile.dbf")
   ENDIF
ENDIF
0
 

Author Comment

by:falvarad
ID: 36545548
It looks good but the zip file is not there.

Thanks
0
 
LVL 4

Expert Comment

by:wcsoctu
ID: 36545566
localfile.dbf was just an example.  Use any folder/filenames you want.
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:falvarad
ID: 36545659
I'm sorry I'm talking about the zip file that contain wwUtIPStuff and wwUtils.prg
SET PROCEDURE TO wwUtils.prg
SET CLASSLIB TO wwIPStuff
0
 
LVL 4

Accepted Solution

by:
wcsoctu earned 500 total points
ID: 36545683
0
 

Author Closing Comment

by:falvarad
ID: 36545707
Thank you, i will test this but it seems exactly what I need.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question