Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an application in vb6 with access database My client now want to use it on lan. How to do this and what changes I have to make in my coding ? please help me
Posted

1 solution

Several ways, all of which are easily googled.

If it is only accessing the database over LAN, put the database somewhere where everyone who needs it can access it, change the connection string and you're done.

If the application instances need to communicate, create one main instance on the server.
Have this program do the listening and the other program(s) do the connecting. Once connected you can communicate back and forth using SendData and the DataArrival event. Check out Winsock Client/Server apps in the Code Bank.



You could probably use TCP/UDP too. Here is short example for UDP (two computers only)

C#
UDP only works on a one-to-one basis. If OP will have more than two apps running then TCP will have to be used but if OP will only have two apps and no more then UDP is the better way to go since it is connectionless and simpler to make that TCP

For UDP here is a simple two-client VB project
Make two VB projects. Call one of them Client1 and the other Client2
Add to each project:
1 Textbox called "Text1" make this big. Set it to Multiline=True and set Vertical Scrollbar. This is for accumulating messages
1 Textbox called "txtMessage". This one if for typing in your message to send to other end
1 Command Button called "Command1"
1 Winsock Control. 

To Client1 copy and paste below code

<pre lang="vb">Option Explicit

Private Sub Form_Load()
 Winsock1.Close
 Winsock1.Protocol = sckUDPProtocol
 Winsock1.RemoteHost = "255.255.255.255"   ' Must have remote IP Address
 Winsock1.RemotePort = 1001                ' Must have remote Port Number
 Winsock1.Bind 1002                        ' Must Bind our Local Port NUmber
 Caption = "Client 1: IP = " & Winsock1.LocalIP & ", Port = " & Winsock1.LocalPort
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
 Dim str As String
 Winsock1.GetData str, vbString
 Text1.Text = Text1.Text & str & vbCrLf
End Sub
Private Sub Form_Unload(Cancel As Integer)
 Winsock1.Close
End Sub

Private Sub Command1_Click()
 Text1.Text = Text1 & txtMessage.Text & vbCrLf
 Winsock1.SendData txtMessage.Text
 txtMessage.Text = ""
End Sub


To the other project, Client2 copy and paste the below code
VB
Option Explicit
Private Sub Form_Load()
 Winsock1.Close
 Winsock1.Protocol = sckUDPProtocol
 Winsock1.RemoteHost = "255.255.255.255"   ' Must have remote IP Address
 Winsock1.Bind 1001                        ' Must Bind our Local Port Number
 Winsock1.RemotePort = 1002                ' Must have Remote Port Number
 Caption = "Client 2: IP = " & Winsock1.LocalIP & ", Port = " & Winsock1.LocalPort
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
 Dim str As String
 Winsock1.GetData str, vbString
 Text1.Text = Text1.Text & str & vbCrLf
End Sub
Private Sub Form_Unload(Cancel As Integer)
 Winsock1.Close
End Sub
Private Sub Command1_Click()
 Text1.Text = Text1 & txtMessage.Text & vbCrLf
 Winsock1.SendData txtMessage.Text
 txtMessage.Text = ""
End Sub

Thanks to jmsrickland, VBForums

I hope this gets you onto right track
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900