Solved

DB problem with Stand alone CGI.

Posted on 2000-03-17
13
1,090 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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.

920 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

14 Experts available now in Live!

Get 1:1 Help Now