Solved

DB problem with Stand alone CGI.

Posted on 2000-03-17
13
1,084 Views
Last Modified: 2013-11-18
//////////////////////////////////////
// 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
Comment
Question by:HamidHossain
  • 5
  • 4
  • 2
  • +2
13 Comments
 

Author Comment

by:HamidHossain
Comment Utility

No Answer, No Comments until NOW !!!

Strange !!!

0
 
LVL 13

Expert Comment

by:Epsylon
Comment Utility
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
 
LVL 1

Expert Comment

by:snoop_doggy_dogg
Comment Utility
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
 
LVL 12

Expert Comment

by:Faruk Onder Yerli
Comment Utility
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
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
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
 

Author Comment

by:HamidHossain
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
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
 

Author Comment

by:HamidHossain
Comment Utility
Wow kretzschmar,

harry up, that problem shut-downing me ;)

do you have an idea about equalizer
 comment ?!
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
Comment Utility
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
 
LVL 13

Expert Comment

by:Epsylon
Comment Utility
Am I invisible?
0
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
ehm, yes eps, didn't seen your comment above until yet :-)
0
 

Author Comment

by:HamidHossain
Comment Utility
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
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
hi hamid,

glad to be of service :-)
good luck again

meikl
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now