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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating a .ddl using ADO to access SQL server 1

Status
Not open for further replies.

wrockleberry

Programmer
Feb 5, 2004
7
US
I am trying to create a DLL that can be called to update a SQL server. I am able to pass the correct parameters to the routine, but when I get to the first line refencing either the ADO connection, or the ADO dataset, even just to set the command text The program stops with the message:
Project raised exception class EAccessViolation with message 'Access violation at address 0024FF5A in module xx.dll'. Read of address 00000064.

In the IDE I am able to open and close the connection as well as the dataset, but when the DLL is loaded from another program and called the access violation happens. I have commented out all of the references to the datatables and the dll runs fine.

I created a datamodle in the LIBRARY module to add the ADOconnection, the ADOdataset, and the delphi datasource, the datamodule is referenced in the uses clause of the module that contains the ADO statements.

Any thoughts on what might be happening would be appreciated.

Thanks
 

The program using the DLL is a Deplhi app? May be it is better to use a run-time package instead of a DLL.

buho (A).


 
Hi wrockleberry,

just add CoInitialize; to your constructor routine and CoUninitialize; to the destructor routine and add 'ActiveX' to your uses unit list. Delphi adds these statements automatically when creating a normal form app but not with DLL's , services, threads and so on...

Cheers,
Daddy

--------------------------------------
What You See Is What You Get
 
Thanks for the insight. I added the ActiveX module to the uses clause, however, I am unsure about the contructor and destructor. I created a datamodule and use the ado connection and ado dataset from the ADO tab in the IDE. I don't know where to find a contructor/destuctor. I tried viewing the data module as code, but still don't know where to add the additional code.

By the way, this dll will be used in a VB6 program as well as a Delphi program, so I do need to make it a dll.

Thanks for the help
 
in the object inspector, click on the events tab when viewing the datamodule form then doubleclick datamodulecreate (constructor) and datamoduledestroy (destructor) this will create the needed routines...

hth,
Daddy

--------------------------------------
What You See Is What You Get
 
After thinking about your original post, I pulled the ADO connection object out of the data module and created the constructor and the deconstructor in code, and the calls to the DLL are working correctly. I think now I will go back and try putting the code in the events you mentioned in your second post and make it a bit "cleaner".

Thanks again for the help.

 
no problem,

we're all here to help each other out ;)



--------------------------------------
What You See Is What You Get
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top