PDA

Click to See Complete Forum and Search --> : How to create a database dll with several classes


nielsvdc
Apr 27th, 2001, 02:54 AM
Dear all,

I want to create one dll for different programs in my company. Per program
I want to create one class in the dll, but also some common classes, which
contain functions that are used in more then one program. All functions
are database related. How can I create a way to use one database
connection through one of the common (main) classes, but use that
connection in all of the functions in the other classes?

Theoretic example:

cls1 -> open connection1
cls2 -> function1 using cls1/connection1 to query db
cls3 -> function2 using cls1/connection1 to query db

I've tried several thing, but they all ended up with opening another
connection through cls1.

Can you maybe give some example code when you give an answer?

Thanks,
Niels van de Coevering

simonm
Apr 27th, 2001, 05:43 AM
I know this is not quite what you were asking for but have you considered taking advantage of connection pooling?

Pass the connection string to each procedure that accesses the database and use that string to open a new connection object. If the connection string is identical to another connection (that has recently been used), this existing connection will be reused (instead of establishing a new one).

NB: User name and Password must not be part of the connection string.

nielsvdc
Apr 28th, 2001, 05:34 AM
No, this is not quite what I need. The functions in the classes contain one sql statement. What the program does is that we scan in a barcode and after that serveral of these functions have to get recordsets back to the program, to be able to identify a lot of things. What we're even doing now is that we keep the connection to the database open, because it could be that we scan a barcode within 10 seconds and then we need a fast response from the program, as we now have withing one second.
I want to make one dll for every program we have doing these kind of things, to get the recordsets. Because for all programs some functions we use are the same, but there are also different ones.