Solved

DataModules in Delphi DLLs

Posted on 2001-09-14
9
414 Views
Last Modified: 2010-04-06
I require to create a dll with a DataModule which I can use from my application and to avoid double login to a Sybase Database when the tables are opened as I have logged in initially to the database.

0
Comment
Question by:wksome
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 4

Accepted Solution

by:
fva earned 50 total points
ID: 6482506
You will _have_ to go for runtime packages both in your DLL and in your app. Actually, you could even make your DLL to be a runtime package itself.

Rough guideline:
For start, compile your app with runtime packages (Project/Options/Packages/Runtime checkbox). Then create a package (I would recommend using that ShareMem unit in the package _and_ in the app) and set it to compile with runtime, too. Add a datamodule to the new package.

Go back to the app, include the DM unit you created above and add the package created above to the list of runtime packages of the project. Use the DM as if it's included in the app itself. The actual code of the DM will reside in the DPL file of the new package.

Caveats:
Do not forget do distribute all the DPL's required (Delphi's and yours, too)
When auto-compiling more than 2 levels of packages all sort of weird things happen (at least in D3 - yes I'm still on D3)
The compiler gets fuzzy with optimization of embedded functions in projects using runtime pk.
...

All in one, you should accept the extra Sybase connection as a fact of life instead of going runtime pk unless you really _have_ to do this DLL stuff (e.g. if you want to implement some plug-in features)

All above opinions are based on D3 over Oracle experience. Other versions or DBMS backends might not fit my words :).

F.
0
 
LVL 4

Expert Comment

by:fva
ID: 6482513
BTW, you may copy the logged-in DB.Params from the app to the DM.DB in the DLL and log in again (i.e. if you're not concerned with the presence of multiple connections but rather with user's conveniance of not having to log in twice). In that case please DO use ShareMem in the DLL and in the app.

F.
0
 
LVL 4

Expert Comment

by:jsweby
ID: 6482611
Why does he have to go go for a runtime package? I have datamodules in DLLs and they work fine.

J.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:fva
ID: 6482671
Yes, but I guess you maintain a distinct connection (TDatabase and eventually TSession) in the app and in the DLL. If you try to use the same TDatabase for objects in the app and in the DLL then the problems start to appear because there are global variables (Session, Sessions, ...) that is instantiated from separate code in app and in DLL and then you get different variables for the same meaning.

The problems might not appear in some patterns of usage but they are still there and might produce unwanted effects or even errors.

F.
0
 

Author Comment

by:wksome
ID: 6482904
I would prefer jsweby's way of using DLLs instead of packages. Does jsweby have some tips please?

0
 
LVL 4

Expert Comment

by:fva
ID: 6483116
I'm afraid that it means you'll go for a separate connection to Sybase, but I might be wrong. I'm listening.

F.
0
 
LVL 4

Expert Comment

by:jsweby
ID: 6488657
Sorry, didn't get any emails to say this topic had been updated. FVA is right, my method unfortuntely involves a whole new connection to the database which is clearly unsuitable for your needs, sorry to get your hopes up!

J.
0
 
LVL 17

Expert Comment

by:geobul
ID: 9308030
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

accept fva's comment as answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Thanks,

geobul
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Making delphi communicate with a c# service 16 122
How to renew a Delphi rad-studio licence? 5 76
Adoquery sql  left join does not work 25 104
Delphi and Access based Enumeration 9 77
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question