Solved

Communication between two programs

Posted on 2006-07-02
12
371 Views
Last Modified: 2013-11-13
Hello everyone!

I have an urgent problem.  I have made a program that processes and records data at a business which has two locations.  I need to figure out how to make the programs send files back and forth to one another daily.  Can anyone help me!?!

Thanks!
Banks
0
Comment
Question by:zraptor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +2
12 Comments
 
LVL 27

Expert Comment

by:Dabas
ID: 17029018
Hi Banks

You have to provide a little bit more information.
What database?
Are the two companies connected to the internet, or to each other is some way or other?


Dabas
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 17029078
you can use winsock in doing this...
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 17029082
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:zraptor
ID: 17029100
The program needs to be able to send the database file it creates to the program at the other location.  Both locations have access to the internet.

I will check out that tutorial.
0
 
LVL 27

Expert Comment

by:Dabas
ID: 17029120
zraptor,
You have not answered my first question. What database? MSAccess mdb? SQL Server? Whjcjh version?
Sending the database file can be inpractical, specially if it is large.
If SQL Server then replication might be given serious consideration.

Dabas
0
 
LVL 9

Expert Comment

by:Naveen Swamy
ID: 17029123
you need to be clear about what you want, the scope of the question is very wide,

some of the available options are :

1) Ado can handle remote ips and database connectivity, (whole lot of examples available already on the net )
2) Winsocks to t/f data (refer www.vbip.com)
0
 

Author Comment

by:zraptor
ID: 17029818
The database's are Excel spreadsheets.  I need both programs to be able to send the spreadsheets to each other directly.  I don't want to use a FTP server on the internet or anything like that, I need to be able to send the files directly to the other computer.
0
 
LVL 15

Accepted Solution

by:
JackOfPH earned 500 total points
ID: 17034721
here is the code in which you can send files across a network... just create two projects server and client. make both .exe

sorry here is the code...

Here's the client..it has a timer , a winsock control, a commondialog control, two textboxes, and three buttons.

***************************begin client ***********************
Option Explicit
Private Sub Command1_Click()
   If cliSock.State <> 0 Then
       cliSock.Close
   End If
   Unload Me
End Sub

Private Sub Command2_Click()
cliSock.Connect Text1.Text, Text2.Text
End Sub

Private Sub Command3_Click()
Dim filename As String
On Error GoTo errhan
   'open a file, and send it to the client as binary
   CommonDialog1.ShowOpen
   filename = CommonDialog1.filename
   Dim str() As Byte
   Open filename For Binary As #1
   ReDim str(FileLen(filename))
   Get #1, , str
   Close #1
   cliSock.SendData str
   Exit Sub
errhan:
msgbox "error"
End Sub



Private Sub Timer1_Timer()
 Select Case cliSock.State
Case 0
   Me.Caption = "Closed"
Case 1
   Me.Caption = "Open"
Case 2
   Me.Caption = "Listening"
Case 3
   Me.Caption = "Connection pending"
Case 4
   Me.Caption = "Resolving host"
Case 5
   Me.Caption = "Host resolved"
Case 6
   Me.Caption = "Connecting"
Case 7
   Me.Caption = "Connected"
Case 8
   Me.Caption = "Peer is closing the connection"
Case 9
   Me.Caption = "Error"
End Select
End Sub


********************end client *******************************
create a new projects...
Here's a server:
It's got a winsock control, a textbox, a timer, and two command buttons.

******************start server********************************
Option Explicit
Dim x As Long       'Byte counter variable
Dim str() As Byte   'Byte variable

Private Sub Command1_Click()
  'Check the connection state before closing
   If svrsock.State <> 0 Then
       svrsock.Close
   End If
   Unload Form1
   Unload Me
End Sub


Private Sub Command2_Click()
svrsock.LocalPort = Text1.Text 'Set the local port to listen on
svrsock.Listen
End Sub

Private Sub Form_Load()
'Command1.Top = Me.ScaleHeight - Command1.Height
x = 1
End Sub

Private Sub Form_Resize()
'Command1.Top = Me.ScaleHeight - Command1.Height
End Sub

Private Sub Form_Unload(Cancel As Integer)
   Unload Form1

End Sub

Private Sub svrSock_ConnectionRequest(ByVal requestID As Long)
svrsock.Close             'Close the socket
svrsock.Accept requestID  'Accept incoming call
End Sub

Private Sub svrSock_DataArrival(ByVal bytesTotal As Long)
      On Error GoTo errhan
       svrsock.GetData str, vbArray + vbByte        'get binary data
       Open App.Path & "\tempfile" For Binary As #1 'open a tempfile for storage
       Put #1, x, str                               'Start creating file at first Byte
       Close #1                                     'Close the file
       x = (x + 1) + UBound(str) ' This counter is to save the last byte stroed in the file and resume
       Command1.Caption = x
       Exit Sub
errhan:
      MsgBox Err.Number & Err.Description
End Sub

Private Sub Timer1_Timer()
 Select Case svrsock.State
Case 0
   Me.Caption = "Closed"
Case 1
   Me.Caption = "Open"
Case 2
   Me.Caption = "Listening"
Case 3
   Me.Caption = "Connection pending"
Case 4
   Me.Caption = "Resolving host"
Case 5
   Me.Caption = "Host resolved"
Case 6
   Me.Caption = "Connecting"
Case 7
   Me.Caption = "Connected"
Case 8
   Me.Caption = "Peer is closing the connection"
   svrsock.Close
   svrsock.Listen
Case 9
   Me.Caption = "Error"
End Select
End Sub




*******************end server********************************

0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 17034726
I use winsock control because it is the simplest... but if you want to use the winsock.dll just go to www.vbip.com they have tutorials on what you need...

0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 17034766
0
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 17036921
What you might want to think about is simply uploading this information to a FTP website along with a bogus text file the text file acts as an indicator to the other application that its ready to download the file on the other end. When the transfer is complete remove the file.

You can use WinInet API's to access data over an http or ftp url.
0
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 17036937
<<< I don't want to use a FTP server on the internet or anything like that, I need to be able to send the files directly to the other computer.

I  missed that part, however you might want to reconsider this option. It's secure and most reliable and offers a backup method.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best way to parse out a json string in VB6? 10 385
WPF - Tooltips for ComboBox items 5 120
Re-position sub-options beneath the TAB 7 111
Automatic Email Reminder 4 94
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

737 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