Solved

DB problem with Stand alone CGI.

Posted on 2000-03-17
13
1,126 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +2
13 Comments
 

Author Comment

by:HamidHossain
ID: 2631009

No Answer, No Comments until NOW !!!

Strange !!!

0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2631130
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
ID: 2631467
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
Industry Leaders: 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!

 
LVL 12

Expert Comment

by:Faruk Onder Yerli
ID: 2631604
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
ID: 2631834
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
ID: 2632733
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2632842
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
ID: 2632897
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
ID: 2632969
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
ID: 2633220
Am I invisible?
0
 
LVL 27

Expert Comment

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

Author Comment

by:HamidHossain
ID: 2635117
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
ID: 2635149
hi hamid,

glad to be of service :-)
good luck again

meikl
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi 2 91
Having trouble setting Apache to recognise 2 vitual sites (on different drive). 3 178
Grunt Copy file to another destination. 1 95
DBCtrlGrid, Delphi, Scroll 8 86
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa‚Ķ
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.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to count occurrences of each item in an array.

734 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