Click to See Complete Forum and Search --> : Kind of hard question I think?


Moretic
August 27th, 2001, 07:29 AM
I have for some time planed to get my databaseapp working but I need to add some features to it. I need to start it as a "Server" that ppl can connect to
and add, update, delete or search in the database from some kind of clientapp.
I use a standard Microsoft database made in access(*.mdb) and I have made all features execpt to search and "sever" abilities, these 2 I dont know how to do.

Please help me with this!

MvH Mattias Holmström(Sweden)

Cimperiali
August 27th, 2001, 07:49 AM
May be you have to trsnsorm your app in an ActiveX exe running as remote component. However, access will give you some maddtime trying to use locked tables...

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater

Cakkie
August 27th, 2001, 08:14 AM
You can connect to an mdb using ADO. So you can place your mdb somewhere on the network, and people can connect to it. It's like connecting to a file on your local disk, only over a network, and probably a bit slower.

There are alternatives, like SQL server, which is a *real* database server. But this should be used when the mdb is not capable of getting the wanted performance.

About the searching, that isn't to hard. There are several posibilities.
1) search on the recordset: use the available commands of the recordset object to search the data. Commands like Find, Filter, or any variants of that should be available depending on the data access provider you are using (ADO or DAO).

2) select the filtered data in a recordset. In stead of opening a table, and then searching the recordset, open the filtered data (like all names starting with the letter A and work with that. This is probably the faster one

Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

Moretic
August 27th, 2001, 09:32 AM
I know that it is possible to connect to a remote server but I havent got a clue on how to do soo, I dont even know how to get the "Server" up and running.
I also know what SQL is and thats not an option, there will be about 5 ppl using
my software so I dont really need some "Superserver".

This is what I need help with...
making the "server" listen to some port like 2000 and communicate with that port
with the clients that connects.
making the "server" able to resive data from that port from the client and be
able to identify the user and then store that data

All I really need is some info on how to send and resive data between my local(private) computer and some friend computers wich isnt on the same LAN, all this with my own app, please help me with this

MvH Mattias Holmström(Sweden)

Cakkie
August 27th, 2001, 09:41 AM
If you really want to do it the hard way, there's always winsock. With this you can create sockets that connect to a specific computer on a specific port, where another winsock is listening. Most important properties of these controls

LocalPort : needed at the server, settign the port on which it will listen
Listen : open the port for listening

Connect : connects to a given adress and port

After the connect, the ConnectionRequest event at the server will fire, and you must accept the connection there, otherwise it will be rejected. Once the connection is open, you can send data acros using the SendData method, which triggers the DataArrival event at the other side, however, I would just stick with ADO or DAO to deal with the database stuff. Of course, for some actions you might want to use winsock, like sending commands to back up the database or so, but definitly not for sending that amount of data.

Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

Moretic
August 28th, 2001, 06:10 AM
I havent ever used winsock but last night I tried but I didnt get the server and client to communicate, I think, any idea on how I can see if they are communicating, like with a textbox?

Cakkie
August 28th, 2001, 06:35 AM
Ok, i'll suplly some code

' server
' add a textbox to the form, set multiline property to true
' scrollbars to vertical
' add a button to the form
' add 2 winsocks to the form
private Sub Winsock2_DataArrival(byval bytesTotal as Long)
Dim strData as string
Winsock2.GetData strData
Text1.Text = Text1.Text & "Received data: " & strData & vbCrLf
End Sub

private Sub Command1_Click()
Winsock1.LocalPort = 1234
Winsock1.Listen
Text1.Text = Text1.Text & "Opened socket for listening" & vbCrLf
End Sub

private Sub Winsock1_ConnectionRequest(byval requestID as Long)
Winsock2.Accept requestID
Text1.Text = Text1.Text & "Connection accepted from " & Winsock2.RemoteHostIP & vbCrLf
End Sub


' Client
' add textbox, multiline, vertical scroll
' add button
' add 1 winsock
private Sub Command1_Click()
Winsock1.RemoteHost = InputBox("Remote host")
Winsock1.RemotePort = 1234
Winsock1.Connect
Text1.Text = Text1.Text & "Connecting to " & Winsock1.RemoteHost & vbCrLf
End Sub

private Sub Winsock1_Connect()
Text1.Text = Text1.Text & "Connected to " & Winsock1.RemoteHost & vbCrLf
Winsock1.SendData InputBox("Enter data to send")
End Sub



When running the samples, press the button on the server, a message should appear in the textbox
On the client, press the button, enter the name or ip of the pc you want to connect to (for testing, this is probably the name op the pc you are working on)
After the connection has been made, enter some text in the inputbox. At the server, you should see the message arrive.

The reason I used two winsock controls at the server, is because this way, you can accept multiple connection. Using a control array, you can load a new Winsock2 to accept the next connection. Of course, this is only a small example. The hard part is yet to come (at least for you), and that is to develop a 'protocol' to comunicate, with this I mean that if the servr receives the string "USER Cakkie", that it knows it must send back "Password required for user Cakkie", or something like that.

Good Luck


Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

Moretic
September 26th, 2001, 11:44 AM
ok, I have tried this code now, took some time, but it doesnt work.
the "server" doesnt get any text but the client says that is did connect.

"Server", Opened socket for listening
"Client", Connecting to 212.217.236.37
"Client", Connected to 212.217.236.37

after this there comes no more, please help

Moretic