Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM Client/Server » View Thread |
Messages 1 to 10 of 24 total |
Accessing files in relative pathes on a client/server system |
Tue, Nov 20 2007 1:00 PM | Permanent Link |
Ralph | Dear Tim,
we haven't heard us lately. I am a satisfied DBISAM user (registered for TechnoLab GmbH and 4-Text). Maybe you remember. Last time we talked about big blob fileds... Anyway... I have a problem. But let me explain you first something: We have a local database with a table that contains the relative path in a string field to a file, e.g. "files\mypic.jpg". This is in SessionType relatively easy to access, e.g. via ShellExecute. Now we convert the database to Client/Server mode. How can I open for example this file in a clinet server mode. We use the dbsvr.exe and the admin tool. Can I use any event of the dbsrvr.exe-tool to open the file with a relative path of the desired database (running in/at dbsvr.exe)? If yes, could you please give me an example how this would work in Client/Server mode. the files are in a relative directory in the database direrectory, for example "\data\files". The database is in "data" and the files to open in "data\files" (any format). How can I do that? I really appreciate your help. Thanks in advance. Ralph |
Tue, Nov 20 2007 1:22 PM | Permanent Link |
Eryk Bottomley | Ralph
There are examples in the help file that do this (almost). The main example sends back a text file assuming a fully qualified path name. Since you have a relative path you probably need a snippet from another example (the scheduled backup) as well. Untested (I'm just editing the help example on the fly): procedure TMyForm.ServerProcedure(Sender: TObject; ServerSession: TDBISAMSession; const ProcedureName: String); var TempFileName, TempPath, TempDesc: string; begin if (AnsiCompareText(ProcedureName,'JPGFile')=0) then begin with ServerSession do begin ServerEngine.GetServerDatabase( RemoteParams.ParamByName('DatabaseName').AsString, TempDesc, TempPath); TempFileName:= IncludeTrailingBackslash(TempPath)+ RemoteParams.ParamByName('FileName').AsString; { Now clear the parameters for use in populating the result parameters } RemoteParams.Clear; if FileExists(TempFileName) then begin { If the file exists, use the TDBISAMParam LoadFromFile method to load the file data into the parameter } with RemoteParams.CreateParam(ftBlob,'FileContents') do LoadFromFile(TempFileName,ftBlob); end else { If the file doesn't exist, just create a NULL parameter with the correct result name } RemoteParams.CreateParam(ftBlob,'FileContents'); end; end; end; |
Tue, Nov 20 2007 1:57 PM | Permanent Link |
Ralph | Hi thanks for your quick reply,
do I need to do this in the srvr.exe or in my seperate application...? Thank you again. Ralph Eryk Bottomley <no@way.com> wrote: Ralph There are examples in the help file that do this (almost). The main example sends back a text file assuming a fully qualified path name. Since you have a relative path you probably need a snippet from another example (the scheduled backup) as well. Untested (I'm just editing the help example on the fly): procedure TMyForm.ServerProcedure(Sender: TObject; ServerSession: TDBISAMSession; const ProcedureName: String); var TempFileName, TempPath, TempDesc: string; begin if (AnsiCompareText(ProcedureName,'JPGFile')=0) then begin with ServerSession do begin ServerEngine.GetServerDatabase( RemoteParams.ParamByName('DatabaseName').AsString, TempDesc, TempPath); TempFileName:= IncludeTrailingBackslash(TempPath)+ RemoteParams.ParamByName('FileName').AsString; { Now clear the parameters for use in populating the result parameters } RemoteParams.Clear; if FileExists(TempFileName) then begin { If the file exists, use the TDBISAMParam LoadFromFile method to load the file data into the parameter } with RemoteParams.CreateParam(ftBlob,'FileContents') do LoadFromFile(TempFileName,ftBlob); end else { If the file doesn't exist, just create a NULL parameter with the correct result name } RemoteParams.CreateParam(ftBlob,'FileContents'); end; end; end; |
Tue, Nov 20 2007 2:05 PM | Permanent Link |
Eryk Bottomley | Ralph,
> do I need to do this in the srvr.exe or in my seperate application...? You have to add code like that to the DBISAM server and re-compile it. You then use SrvAdmin to 'register' the stored procedure and grant execute rights to the appropriate user accounts and finally use Session.CallRemoteProcedure from your client application to use the new functionality. Eryk |
Tue, Nov 20 2007 2:14 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Ralph,
Eryk nailed the answer again on this one - what you want is a server-side procedure. -- Tim Young Elevate Software www.elevatesoft.com |
Tue, Nov 20 2007 2:31 PM | Permanent Link |
Ralph | Hi thanks again,
maybe i am a bit silly or sth. So please step by step again. Thank you really in advance. 1. I write this code (above) in the event: "onServerProcedure" in the dbsrvr.dpr-project. 2. I re-compiled it to a new dbsrvr.exe 3. Registering the procedure? But How? Do I need to use the tabsheet "procedures"? or "procedure users" What do I need to type there exactly in? "onServerProcedure"? 4. Which rights are necessary to ececute this procedure? and where can I adjust it? 5. Do I call from my normal application "Session.CallRemoteProcedure" (and nothing more? I mean without parameters or somtething...?!) to execute this procedure? To Tim: Yeah, The server needs to execute (e.g. open a file on a client's demand.)... Any code examples? I really thank you all so much. Thank you. Ralph Eryk Bottomley <no@way.com> wrote: Ralph, > do I need to do this in the srvr.exe or in my seperate application...? You have to add code like that to the DBISAM server and re-compile it. You then use SrvAdmin to 'register' the stored procedure and grant execute rights to the appropriate user accounts and finally use Session.CallRemoteProcedure from your client application to use the new functionality. Eryk |
Tue, Nov 20 2007 2:50 PM | Permanent Link |
Ralph | Hello Tim,
how does it work with a server side procedure. <please please could you give me a useful example? For the client side and the server side that needs to open any file e.g. via shelexecute and all the adjustments in the admin-tool. Sorry for annoying. Thanks so much. Ralph |
Tue, Nov 20 2007 2:58 PM | Permanent Link |
Ralph | I've just read in the help files about server procedures.... is this procedure always
relevant for the selected record in the table? Thanks, Ralph Ralph <ralphdietrich@gmail.com> wrote: Hello Tim, how does it work with a server side procedure. <please please could you give me a useful example? For the client side and the server side that needs to open any file e.g. via shelexecute and all the adjustments in the admin-tool. Sorry for annoying. Thanks so much. Ralph |
Tue, Nov 20 2007 3:27 PM | Permanent Link |
Eryk Bottomley | Ralph,
> 1. I write this code (above) in the event: "onServerProcedure" in the dbsrvr.dpr-project. > > 2. I re-compiled it to a new dbsrvr.exe Yes. > 3. Registering the procedure? But How? Do I need to use the tabsheet "procedures"? or > "procedure users" What do I need to type there exactly in? "onServerProcedure"? I always do it in code so I don't remember the UI too well for this. The procedure name in the example I posted is 'JPGFile' and you add that to the appropriate database using the 'Procedures' tab. The 'Procedure Users' tab then specifies whether specific users can execute the procedure or not (Admin user can always access procedures by default). > 4. Which rights are necessary to ececute this procedure? and where can I adjust it? 'Execute' ...and that is the only right appropriate to a stored procedure. > 5. Do I call from my normal application "Session.CallRemoteProcedure" (and nothing more? I > mean without parameters or somtething...?!) to execute this procedure? No, you call it along the following lines (adapting a help file example again): begin with MyRemoteSession do begin RemoteParams.CreateParam(ftString,'DatabaseName').AsString:='Main'; RemoteParams.CreateParam(ftString,'FileName').AsString := MyTable.FieldByName('FileName').AsString; try { Now call the procedure } CallRemoteProcedure('JPGFile'); if not ParamByName('FileContents').IsNull then begin ParamByName('FileContents').SaveToFile( MyTable.FieldByName('FileName').AsString); MyShellExecute(MyTable.FieldByName('FileName').AsString); end; except ShowMessage('There was an error calling the '+ 'server-side procedure'); end; end; end; ....there is a silly assumption there since I saved the JPG file to the client hard disk using the relative path and name from the database without checking if it is valid or if the file already exists etc. Typically you would get a temporary file name from the OS and create the local copy in the user's temporary files directory (and also erase it when finished). 'MyShellExecute' is just an imaginary wrapper for ShellExecute since I can't be bothered looking up what parameters it takes Eryk |
Tue, Nov 20 2007 4:08 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Ralph,
<< I've just read in the help files about server procedures.... is this procedure always relevant for the selected record in the table? >> Server-side procedures have no relation whatsoever to a table. -- Tim Young Elevate Software www.elevatesoft.com |
Page 1 of 3 | Next Page » | |
Jump to Page: 1 2 3 |
This web page was last updated on Friday, April 19, 2024 at 07:09 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |