Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Client server + ado

Status
Not open for further replies.

GCTIberica

Programmer
Jun 20, 2003
30
ES
I hope someone can help!

I have a client server application using Indy components.
The server accesses a database using ADO components.
I have one ADOQuery to access the database. However, as this is a server, I need more than one Query! Therefore, I want to use 10 different query components to access the database, and want to enable the query components to each have 10 concurrent access to the socket!
Therefore, in each socket access, I must assign a different query component and work out when this is free so it can be assigned to another socket access.

Does anyone understand what the hell I am talking about, because sometimes I dont! :-|

I hope someone can help because I have very little time to do this and I am quite confused, as this is my first client server application.

I have code if anyone needs to see it.

Thanks in advance

 
It all sounds pretty straight-forward to me.

You want a server which allows up to 100 TCP/IP connections simultaneously, with each connection performing a query against the database.

Is there any reason you are limiting yourself to 10 query components?

I'd use a TIdTCPServer component with a TIdThreadMgrPool that allows up to 100 connections. The trickiest part is providing a thread-safe pool of TADOConnections (not sure how it would handle a single ADOConnection), you could start out by allowing each thread to create its own TADOConnection - you will probably need to include the following line in you project source:

CoInitFlags:= COINIT_MULTITHREADED;

This will allow your ADOConnections to be used in a multi-threaded environment. Create the ADOConnection as follows:

CoInitialize(nil);
Connection := TADOConnection.Create(nil);
Connection .LoginPrompt := False;
Connection .ConnectionString := ConnectionString();
Connection .Open;

and destroy them like this:

aConnection.Close;
FreeAndNil(aConnection);
CoUninitialize();

Its important to use the CoInitialize and CoUninitialize.


See how that goes for now :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top