Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 7 of 7 total |
Trying to get a basic DLL to work using DBISAM 3.30 |
Wed, Oct 14 2009 12:35 PM | Permanent Link |
"Mike Saunders" | Hi everyone
I am trying to get my first DLL to work All works OK until I try to incorporate DBISAM 3.30 Here is the code below I have trimmed it down to the bare essentials so it doesn't do much in its present form I get an AV when trying to execute DM.DBISAMSession.Open; I have connected the database and table to a separate session on the DM I am calling this DLL from another delpphi exe on the same PC with the default session. Session type here is stLocal Any ideas Many thanks Mike library TestLibrary; uses SysUtils, Classes, Dialogs, uDM in 'uDM.pas' {DM: TDataModule}; {$R *.res} function DoublePChar(BufferIn, BufferOut: PChar; BufferOutLen: Cardinal; Separator: Char): LongBool; stdcall; begin try DM.DBISAMSession.Open; DM.dbDataBase.Connected := true; DM.tbMeta.Open; except on E: exception do begin MessageDlg(E.message,mtInformation,[mbOK],0); Result := False; end; end; Result := True; end; exports DoublePChar; begin end. -- |
Wed, Oct 14 2009 1:10 PM | Permanent Link |
"John Hay" | Mike
> I am trying to get my first DLL to work All works OK until I try to > incorporate DBISAM 3.30 Here is the code below I have trimmed it down > to the bare essentials so it doesn't do much in its present form I get > an AV when trying to execute DM.DBISAMSession.Open; > > I have connected the database and table to a separate session on the DM > I am calling this DLL from another delpphi exe on the same PC with the > default session. Session type here is stLocal Maybe you are doing it elsewhere but I don't see see where you are creating the datamodule eg dm := tmydatamodule.create(nil) John |
Wed, Oct 14 2009 1:24 PM | Permanent Link |
"Mike Saunders" | >
> Maybe you are doing it elsewhere but I don't see see where you are > creating the datamodule eg dm := tmydatamodule.create(nil) > > John I do not create the DM Dynamically And neither the Session/ Database or Table components Are you saying that in a DLL all DBISAM Components (and all others for that matter) need to be done in this way I am afraid I am a bit dumb when it comes to DLL's just trying to find my way slowly Thanks Mike |
Wed, Oct 14 2009 1:29 PM | Permanent Link |
"John Hay" | Mike
> I do not create the DM Dynamically And neither the Session/ Database or > Table components Are you saying that in a DLL all DBISAM Components > (and all others for that matter) need to be done in this way The datamodule will create all the dbisam components for you but you have to manually create the datamodule. something like dm := tmydatamodule.create(nil); do everything you need with the datamodule; dm.free; John |
Wed, Oct 14 2009 2:27 PM | Permanent Link |
"Mike Saunders" | John Hay wrote:
> Mike > > > I do not create the DM Dynamically And neither the Session/ > > Database or Table components Are you saying that in a DLL all > > DBISAM Components (and all others for that matter) need to be done > > in this way > > The datamodule will create all the dbisam components for you but you > have to manually create the datamodule. something like > > dm := tmydatamodule.create(nil); > do everything you need with the datamodule; > dm.free; > > John Thanks I wil give that a try. Not sure what you mean though about the DM creating all its components How does it know how many tables I want etc Perhaps an example? Thanks Again -- |
Wed, Oct 14 2009 8:26 PM | Permanent Link |
"Raul" | > Thanks I wil give that a try. Not sure what you mean though about the
> DM creating all its components How does it know how many tables I want > etc Perhaps an example? I believe what he meant was that DM will create any components you have placed on the DM - you just need to just create the DM. So in your case it looks like you have a table comopnent called tbMeta on so once DM is created you can just call open as you did (DM.tbMeta.Open wihtout needing to do a separate (DM.tbMeta := TDBISAMTable.Create(nil)) call: Any run-time components you obviously need to create and free yourself in code. For example you could do something like this (assuming you're querying from table you already have. and add better exception/error handling ,etc) : var myQuery: TDBISAMQuery; .... myQuery:=TDBISAMQuery.Create(nil); try myQuery.SessionName := DM.DBISAMSession.SessionName; myQuery.DatabaseName := DM.dbDatabase.DatabaseName; myQuery.SQL.Text := SqlText; //add your own SQL myQuery.Open; //TODO : do something useful with it now myQuery.Close; finally myQuery.Free end end; .... Obviously use the session and database you already have for these (rather than default ones) since your DLL might be called from any thread and such. Raul |
Thu, Oct 15 2009 5:35 AM | Permanent Link |
"Mike Saunders" | Raul wrote:
> > Thanks I wil give that a try. Not sure what you mean though about > > the DM creating all its components How does it know how many tables > > I want etc Perhaps an example? > > I believe what he meant was that DM will create any components you > have placed on the DM - you just need to just create the DM. > > So in your case it looks like you have a table comopnent called > tbMeta on so once DM is created you can just call open as you did > (DM.tbMeta.Openwihtout needing to do a separate (DM.tbMeta := > TDBISAMTable.Create(nil)) call: > > Any run-time components you obviously need to create and free > yourself in code. For example you could do something like this > (assuming you're querying from table you already have. and add better > exception/error handling ,etc) : > > var > myQuery: TDBISAMQuery; > > ... > myQuery:=TDBISAMQuery.Create(nil); > try > myQuery.SessionName := DM.DBISAMSession.SessionName; > myQuery.DatabaseName := DM.dbDatabase.DatabaseName; > myQuery.SQL.Text := SqlText; //add your own SQL > myQuery.Open; > //TODO : do something useful with it now > myQuery.Close; > finally > myQuery.Free > end > end; > ... > > Obviously use the session and database you already have for these > (rather than default ones) since your DLL might be called from any > thread and such. > > Raul Thanks. After some refection (which is often the case with me) I realised that was probably what he meant No just need to try this out Mike -- |
This web page was last updated on Friday, March 29, 2024 at 03:30 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |