Solved

DB problem with Stand alone CGI.

Posted on 2000-03-17
13
1,133 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

634 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