• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 378
  • Last Modified:

Communication between two programs

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
zraptor
Asked:
zraptor
  • 5
  • 2
  • 2
  • +2
1 Solution
 
DabasCommented:
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
 
JackOfPHCommented:
you can use winsock in doing this...
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
zraptorAuthor Commented:
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
 
DabasCommented:
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
 
Naveen SwamyCommented:
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
 
zraptorAuthor Commented:
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
 
JackOfPHCommented:
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
 
JackOfPHCommented:
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
 
JackOfPHCommented:
0
 
nffvrxqgrcfqvvcCommented:
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
 
nffvrxqgrcfqvvcCommented:
<<< 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 5
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now