Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1141
  • Last Modified:

DB problem with Stand alone CGI.

//////////////////////////////////////
// Session1 has AutoSessionName enabled.
// Table1 has AutoSessionName in the Session Name property.
//////////////////////////////////////
uses
  Forms;

var
  ScriptPath : String;

///////////////
// onCreate  //
///////////////
begin
  ScriptPath := ExtractFilePath(Application.ExeName);
 
  Table1.DatabaseName := '';
  Table1.TableName    := ScriptPath + 'myDB.db';
 
  Session1.NetFileDir := ScriptPath;
  Session1.PrivateDir := ScriptPath;
  Session1.Active     := True;
end;

///////////////
//  xAction  //
///////////////
begin
  // Get some values from user by Request.
  ...
  ...
  ...
 
  // Opening Table1
  try
    Table1.Open;

    // do some stuff
    ...
    ...
    ...
  finally
    Table1.Close;
  end;
end;


///////////////
// onDestroy //
///////////////
begin
  Session1.Active := False;
end;
//////////////////////////////////////

I built my stand alone CGI using the above structre.  that should work good. but I get the following exception when multi-user try to use the CGI at the same time.

-----------------------------------
Internal Server Error 500
-----------------------------------
Exception: EDBEngineError
Message: Network initialization failed. File or directory does not exist. File: C:\PDOXUSRS.NET Permission denied. Directory: C:\
-----------------------------------

so, I solved that problem by deleting the file PDOXUSRS.NET, which will be generated automaticaly at the next request from user. but also and also multi-user causes the same problm !!!.  I have also the same code with TQuery component and the same problem occures.

notice that I dont have C:\PDOXUSRS.NET .. the file is in D:\MyServer\Cgi-bin\PDOXUSRS.NET !!

if (IMakeMisstake) then begin
  Please;
  TellMeWhatToDo;
end;

;)
Regards
Hamid
0
HamidHossain
Asked:
HamidHossain
  • 5
  • 4
  • 2
  • +2
1 Solution
 
HamidHossainAuthor Commented:

No Answer, No Comments until NOW !!!

Strange !!!

0
 
EpsylonCommented:
It's weekend so Barry (Inthe) and others, including me, are catching up some sleep after a week of hard work   :o)

About your problem. AutoSessionName is to be used in multi-threaded situations. This is not the case with CGI, so set AutoSessionName to false or switch over to ISAPI, which is multi-threading.
0
 
snoop_doggy_doggCommented:
Doood, it's been a LONG time since I've done Paradox tables, but I would guess that it's not the most reliable DB for a multi-user web server application.  If you insist on using PDox, then maybe you should consider making an ISAPI app instead and then wrap all DB access in critical sections.

Woof!
http://www.woofwoofwoof.com
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Faruk Onder YerliCommented:
U dont use session in the CGI.
you must use database object and you must write program like desktop programming but you  mustn't use GUI object. I can use then & my programs run 50-150 object same time ...
0
 
kretzschmarCommented:
hi hamid,

it sounds that the sessionname-property of
your table-component not contains the session1 as entry

also you can drop your session1-component,
because a default session will created automatically.

sample changes

begin
 ScriptPath := ExtractFilePath(Application.ExeName);
                     
  Table1.DatabaseName := '';
  Table1.TableName    := ScriptPath + 'myDB.db';
                     
  Session.NetFileDir := ScriptPath;
  Session.PrivateDir := ScriptPath;
  Session.Active     := True;
end;

in this case the table property sessionname stays empty

for a multiuseraccess, you must
carry for it providing a different private dir
for each concurrent client-session

hope this helps a bit

meikl
0
 
HamidHossainAuthor Commented:
equalizer,

I understand that I should use TDatabase component so,

  Database1.AliasName    := '';
  Database1.DatabaseName := 'HamidDB';
  Database1.DriverName   := '';
  Database1.Exclusive    := False; //important issue !!
  Database1.ReadOnly     := True;  //important issue !!

  Table1.DatabaseName    := 'HamidDB';  // as above
  Table1.TableName       := 'MyData.DB';

  Session1.Active        := True;
  Database1.Connected    := True;
  Table1.Active          := True;

am I right ?!!

//////////////

for kretzschmar,

I put the same as your comment at the first of my website developing, put when two users use the application an exception with 'Folder is buissy' raised !!.  so I added a session component to avoid that message .. and the exception changed to 'Network initialization failed. File or directory does not exist. File: C:\PDOXUSRS.NET Permission denied. Directory: C:\'

////////////////

any more ideas !!

Regards for all,
Hamid

0
 
kretzschmarCommented:
hi hamid,

'Folder is buissy' comes up because the privatedir
is not shareable by two or more users.

you must provide for each concurrent user-access a different privatedir!

somewhere i've a sample for this.
searching now.

meikl
0
 
HamidHossainAuthor Commented:
Wow kretzschmar,

harry up, that problem shut-downing me ;)

do you have an idea about equalizer
 comment ?!
0
 
kretzschmarCommented:
yup hamid,

found it, well does not match exactly,
but cut off what you need

---- paste begin


                   function randomname : String;
                   var
                     i : Integer;
                     s : String;
                   begin
                     s := '';
                     for i := 1 to 8 do
                       s := s + chr(Random(25)+ 65); {Only Letters from A to Z}
                     randomname := s;
                   end;



                   procedure TForm1.FormCreate(Sender: TObject);
                   var s : String;
                   begin
                     s := Randomname;
                     while DirectoryExists('c:\'+s) do s := Randomname;
                     if createdir('c:\'+s) then
                     begin
                       TestSession.PrivateDir := 'c:\'+s;
                       TestSession.Active := True;
                       { open Database Components }
                       table1.open;
                     end
                     else
                     begin
                       { Problem occured }
                     end;
                   end;

                   procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
                   var
                     Found : Integer;
                     SRec : TSearchRec;
                   begin
                     TestSession.Active := False; {All DatabaseConnections will be closed }
                     { Delete Files in temporary Directory }
                     Found := FindFirst(TestSession.PrivateDir+'\*.*', faAnyFile, SRec);
                     while Found = 0 do
                     begin
                       If SRec.Name[1] <> '.' then {Ignore Entries . and .. }
                         Deletefile(TestSession.PrivateDir+'\'+SRec.Name);
                       Found := FindNext(SRec);
                     end;
                     FindClose(SRec);
                     rmdir(TestSession.PrivateDir);
                   end;

---- paste end

about equalizers comment:
i guess this makes no difference,
because a database is just like an alias replacement and
makes more sense for sql-databases.

hope it helps a bit

meikl
0
 
EpsylonCommented:
Am I invisible?
0
 
kretzschmarCommented:
ehm, yes eps, didn't seen your comment above until yet :-)
0
 
HamidHossainAuthor Commented:
kretzschmar,

ooooh, I cant beleive, I did it !!

Was that a magic ?!!!

Special thanks kretzschmar, I gave you Excellent.

Thanks for everybody helps.

Regards,
Hamid
0
 
kretzschmarCommented:
hi hamid,

glad to be of service :-)
good luck again

meikl
0

Featured Post

Independent Software Vendors: 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!

  • 5
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now