?
Solved

ADODataset in dll and ShareMem

Posted on 2003-02-25
7
Medium Priority
?
297 Views
Last Modified: 2010-04-04
First of all, is it possible to declare function of type TDataSet with stdcall
like
function NotesList(sOwner:string):TDataSet;stdcall;
 If it is, should I include ShareMem in my dll?

Or there is a better way to do this?

What I want to do is to separate data access from the rest of my application, because database might be Access, SQL Server or Firebird. They all have slightly different SQL syntax.
But I still want to get TDataSet or TADODataSet from the data access layer because I want to be able to do further processing with it before binding to a grid.

I know I can do that by writing an additional class that will be in exe, but I am considering dll for some reasons.
0
Comment
Question by:bogiboy
  • 4
  • 2
7 Comments
 
LVL 9

Accepted Solution

by:
mocarts earned 200 total points
ID: 8023792
first of all your function have a string parameter which requires ShareMem if used in dll.
and yes, if you want pass between exe and dll TDataSet (as it uses strings too) then you need include ShareMem as your first unit in project.

wbr, mo.
0
 
LVL 9

Expert Comment

by:mocarts
ID: 8023814
one note: you should use ShareMem in both - exe and dll

as far as I know, there is two alternatives to ShareMem (which is wraper for DLL) - FastShareMem and MultiMM (search in Google for keywords). but both have some disantvages and advantages (I don't like disantvages in memory managmen - so when I need to use shared memory I use standard ShareMem)

wbr, mo.
0
 
LVL 1

Author Comment

by:bogiboy
ID: 8027262
Thanks mocarts
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 

Expert Comment

by:Rusty_Knight
ID: 8033546
I think it must be
function NotesList(sOwner:WideString):TDataSet;stdcall;

and no problem with ShareMem
0
 
LVL 9

Expert Comment

by:mocarts
ID: 8033602
stdcall is calling convention - it don't manage memory.
from delphi help:
"If a DLL exports routines that pass long strings or dynamic arrays as parameters or function results (whether directly or nested in records or objects), then the DLL and its client applications (or DLLs) must all use the ShareMem unit"

TDataSet uses strings (Filter, Name etc.)
wbr, mo.
0
 

Expert Comment

by:Rusty_Knight
ID: 8033703
mocarts, you are right.
But in this case we send WideString and TDataset automaticaly convert it to string.
0
 
LVL 9

Expert Comment

by:mocarts
ID: 8033741
WideString is a parameter
TDataSet is return type..
where is conversion? :)
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Planning to migrate your EDB file(s) to a new or an existing Outlook PST file? This video will guide you how to convert EDB file(s) to PST. Besides this, it also describes, how one can easily search any item(s) from multiple folders or mailboxes…
Suggested Courses

600 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