Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread Run SQL query: Executable in parent folder, DB in child folder
Tue, Jul 7 2009 5:02 AMPermanent Link

Jonathan Mackey
Basically, my database is in a child folder \DB. My executable is in the root folder.  I'm
trying to run a simple SQL query SELECT * FROM App.  It comes up with the error App.DAT
not found in \ directory - it is in \DB\.  Is there any way that I can point the
TDBISAMQuery to the correct folder?  I'm using v3.30 VCL in Delphi (3.30 for legacy reasons!).

Hope this makes sense!

-Jonny
Tue, Jul 7 2009 5:54 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Jonathan


Either set the DatabaseName in the query or fully qualify the table with the path name in the sql

Roy Lambert [Team Elevate]
Tue, Jul 7 2009 6:36 AMPermanent Link

Jonathan Mackey
Roy Lambert wrote:

Jonathan


Either set the DatabaseName in the query or fully qualify the table with the path name in
the sql

Roy Lambert [Team Elevate]

Hi Roy,

Either way I do it now, it comes up with 'DBISAM Engine Error # 11013 Access denied to
table 'C:\27520.DAT'.  The number changes of the .DAT file changes, but it is the same
error.  It's weird, when I run that SQL in the query analyzer it works.  I'm making sure
the query analyzer is closed before I debug the software!

I'm pretty certain I'm doing something really stupid... i just don't know what...

-jonny
Tue, Jul 7 2009 8:08 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Jonathan


That's a temporary table and you can't access them (apart from as the result set of the query)so yes you're doing something stupid Smiley I guess the thing is that you don't have the table name correct. Can you post the SQL please.

Roy Lambert [Team Elevate]
Tue, Jul 7 2009 8:39 AMPermanent Link

Jonathan Mackey
Roy Lambert wrote:

Jonathan


That's a temporary table and you can't access them (apart from as the result set of the
query)so yes you're doing something stupid Smiley I guess the thing is that you don't have
the table name correct. Can you post the SQL please.

Roy Lambert [Team Elevate]

 dsSingleApplicant := TDataSource.Create(nil);
 qrySingleApplicant := TDBISAMQuery.Create(nil);

 dsSingleApplicant.DataSet := dm.tblApp;
 qrySingleApplicant.DataSource := dsSingleApplicant;
 qrySingleApplicant.DatabaseName := 'DB';

 with qrySingleApplicant do
 begin
   Close;
   SQL.Clear;
   SQL.Text := 'SELECT AppID FROM "C:\Test\DB\App" WHERE AppID = ' + aApplicant.Username;
   Open;
 end;

That's all my code that I have now... before it just said "SQL.Text := 'SELECT AppID FROM
App WHERE AppID = ' + aApplicant.Username;"
Tue, Jul 7 2009 8:46 AMPermanent Link

"Robert"

"Jonathan Mackey" <jonathan.m@mindmill.co.uk> wrote in message
news:B203E8A6-876F-42C5-8CA2-52718A1CDCD2@news.elevatesoft.com...
> Roy Lambert wrote:
>
> Jonathan
>
>
> Either set the DatabaseName in the query or fully qualify the table with
> the path name in
> the sql
>
> Roy Lambert [Team Elevate]
>
> Hi Roy,
>
> Either way I do it now, it comes up with 'DBISAM Engine Error # 11013
> Access denied to
> table 'C:\27520.DAT'.

Set the private directory in the session (session.privatedir := ...).
Windows is not letting ytou write to yhe C\ root.

Robert

Tue, Jul 7 2009 8:54 AMPermanent Link

"Robert"

"Robert" <ngsemail2005withoutthis@yahoo.com.ar> wrote in message
news:0E996C9B-45F8-48C3-8587-4E12810B03B2@news.elevatesoft.com...
>
>
> Set the private directory in the session (session.privatedir := ...).

The procedure you need is in Windows.pas

Function GetWindowsTempPath : string;
var TempFolder : Array[0..MaxPath] of Char;
....
GetTempPath(MaxPath, TempFolder);
result := StrPas(TempFolder);
if (result <> '') and (result[length(result)] <> '\') then result := result
+ '\';

Robert

Tue, Jul 7 2009 9:04 AMPermanent Link

Jonathan Mackey
Thanks Robert! And Roy too!

Got it working using the session.PrivateDir Smile
Tue, Jul 7 2009 9:28 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Jonathan


Robert's post just made me realise that its working but you can't access the result set so as he says set the PrivateDir to somewhere you do have access to or try

dsSingleApplicant.RequestLive := True

so that a temporary table isn't produced.

The other alternative (and I have no idea how it applied to V3) is there were problems with some anti virus systems and some versions of DBISAM (I think it was something about one trying to open whilst the other had it locked) so if setting PrivateDir or RequestLive doesn't sort it then its probably something to do with this.

Roy Lambert [Team Elevate]
Image