?
Solved

Communication between two programs

Posted on 2006-07-02
12
Medium Priority
?
374 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 

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 2000 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

Industry Leaders: 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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

765 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