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!

DLL writing and accessing a DB 1

Status
Not open for further replies.

LucieLastic

Programmer
May 9, 2001
1,694
GB
hi All

I need to write a DLL which will access a Sybase database. It also needs to store global variables between calls and retain DB connection (between calls). I would also like the end user to be able to, say, log on and access to separate DBs simulataneously.

Firstly, haven't written a DLL before and don't know how to go about it. Also, are there any obvious problems with DLLs connecting to a database?

Any input and examples grateful received.

lou
 
Lou, using D6 you can create a dll from file - new - other - dllwizrd (it doesn't do much, but it is a start.

List any functions / procedures under an exports section (below the uses)

Write the routines on another unit (we use a datamodule with an appropriate db connection on it) and compile it up, one dll created.

In the calling program declare types for each routine you want to call, and then variables of thess types. Declare a variable of Hwnd type and assign this equal to the result of a loadlibrary call to your dll. If the returned value > 0 then set the variable (using an @ symbol) to the getprocaddress (using your declared Hwnd) and the routine name. Then just call the variable and it will run your dll routine.
You can then use freelibrary to tidy up at the end.

We have shared db connections fine, but have not used Sybase, I assume it should be fairly straightforward though.

I know it sounds complex, but once you get one working it is pretty straight forward. Robertio
Alias: Robbie Calder
Software Developer
urc@walkermartyn.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top