How to Open a DBF file from Internet Web Server via xBScript

Post Reply
User avatar
RAMESHBABU
Posts: 591
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

How to Open a DBF file from Internet Web Server via xBScript

Post by RAMESHBABU »

Hi

Can anybody help me.

I have the following code to test the xBscript.dll. I have registered the
Xbscript.dll the internet server. And I tried to open a DBF file TEST.DBF through the following code. But it is generating an error to open
the DBF file.

The problem is only to supply the proper path to the DBF.

I don't know how to give the path to open a DBF file from the internet
server.

Please guide me.

- Ramesh Babu P

Code: Select all

<HTML>
  <OBJECT ID="XBScript" WIDTH=0 HEIGHT=0
   CLASSID="CLSID:ADB21CAC-9B03-4D64-9097-83B05741FDAF"
   CODEBASE="http://www.xharbour.com/ondemand/xbscript.cab#Version=2,0,0,2">
   </OBJECT>
 
   <SCRIPT language=XBScript></script>
   <HEAD>
   </head>
 
   <BODY>
      <P>xbScript Sample 1</p>
      <PRE ID="DynBody"></pre>
 
      <SCRIPT language=XBScript>
 
PROCEDURE Main()

SET DATE BRIT
SET CENT ON  
REQUEST CDX

Window:DynBody:innerHTML := "<P>Client Side - Dynamic content.</p>" + ;
                            "<P>Today is: " + dToC( Date() ) +" " + CMONTH(DATE()) +" "+ STR(DAY(DATE()),2)+", " + STR(YEAR(DATE()),4)+"</p>"
DynBody:innerHTML += "<P>xbSCript Version: " + PP_Version + "</p>"
 
CLOSE ALL

DynBody:innerHTML += "<P>File "+CurDrive()+":\"+Curdir()

USE TEST ALIAS TEST EXCLUSIVE NEW VIA "DBFCDX"
INDEX ON first TO test
SET INDEX TO test

PRIVATE nCounter := 1
 
IF USED()
   DynBody:innerHTML += "<P>File "+CurDrive()+":\"+Curdir()+"\TEST.DBF is used at "+TIME()+"</p>"
ELSE
   DynBody:innerHTML += "<P>File "+CurDrive()+":\"+Curdir()+"\TEST.DBF is not used.</p>"
ENDIF
 
DO WHILE !EOF()   
   DynBody:innerHTML += "<P>"+STR(nCounter,3)+". Rec# :" + STR(nCounter) + ", " + test->first + ", " + test->last + ", " + test->street + ", " + test->city + ", " + test->state + ", " + test->zip + "</p>"  
   SKIP
   nCounter++ 
ENDDO
 
DynBody:innerHTML += "<P>No of Records displayed are : "+LTRIM(STR(nCounter-1))+"</p>"
 
CLOSE ALL
 
RETURN

  </SCRIPT>

<P>Eof() ASP Script</p>
 
</BODY>
</HTML>

User avatar
RAMESHBABU
Posts: 591
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Post by RAMESHBABU »

Hi Mr.Enrico

Thank you for your suggestion.

I have already tried it. I am getting the path like:

C:\WINDOWS\DESKTOP

The USE command us always trying to call the DBF file from the
Local system's C:\WINDOWS\DESKTOP instead of the folder from
the ASP code is running in the Internet Server. Just for testing
purpose I have placed the TEST.DBF on C:\WINDOWS\DESKTOP.
And I found the ASP code is working well.

I don't know how to find out the correct path of the TEST.DBF
and assign it.

Try to help.

Regards

- Ramesh Babu P
Gale FORd
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston
Contact:

Post by Gale FORd »

Are you running the script on server side? Try this

cDataPath := Request:ServerVariables["PATH_TRANSLATED"]:item()
User avatar
RAMESHBABU
Posts: 591
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Post by RAMESHBABU »

Mr.Gale and Mr.Enrico

The following is the code for test.asp which I have uploaded in the
WWWROOT folder of my ftp. When I tried to run it from my Internet
Explorer, it is catching an error.

What I found from tests is :

The path it is taking is the path where the XbScript.dll is located on the
Server. example: WINDOWS\SYSTEM32\INETPUB if I run the script from remote server.
C:\WINDOWS\DESKTOP is the path, if run the script from my local system.
And this is becoming the default directory. Here I do not know how to set
the path to the WWWROOT folder in the server.

I have run servervariables.asp, it is working good and showing the values.

As suggested by Mr.Gale:

Code: Select all

cDataPath := Request:ServerVariables["PATH_TRANSLATED"]:item()
I tried find the path thru cDataPath. It is giving me the path like :

PATH_TRANSLATED = C:\Domains\mytestwebsite.com\wwwroot\servervariables.asp

This is my script.

Code: Select all

<%@ Language=XBScript %>

<% #translate Response. => Response: %>

<P>Testing XbScript.dll</p>

<%

TRY
     USE TEST.DBF ALIAS TEST 
     Response:Write( "<P>" + test->first + ", " + test->last + ", " + test->street + ", " + test->city + ", " + ;
                             test->state + ", " + test->zip + "</P>")  
CATCH oErr
     Response:Write( "<P>Make sure TEST.DBF is at specified location (must be located within this site's folder, "+;
                     "and has all permissions</P>" )
     RETURN
END
  
%>
- Ramesh Babu P
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

All my scripts work fine using

Code: Select all

SET DEFAULT TO ( CURDRIVE() + ":\" + CURDIR() )
But you have to run them server side.

EMG
User avatar
RAMESHBABU
Posts: 591
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Post by RAMESHBABU »

Hi Mr.Enrico

Can please give me a working sample asp file.

Regards,

- Ramesh Babu P
User avatar
RAMESHBABU
Posts: 591
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Post by RAMESHBABU »

Mr.Enrico and Mr.Gale

Code: Select all

SET DEFAULT TO ( Server:MapPath( "./" ) )
has served the purpose and it is correctly
pointing to the databse path.

Thanks to you both

- Ramesh Babu P
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

I'm very sorry, I was wrong. I was referring to a CGI scripts. Now I'm aware that you were talking about ASP script. So the correct statement is

Code: Select all

SET DEFAULT TO ( Server:MapPath( "./" ) )
EMG
User avatar
SteveLai
Posts: 11
Joined: Tue Apr 18, 2006 11:43 am
Location: Scotland
Contact:

xbscript.dll

Post by SteveLai »

"I have registered the Xbscript.dll the internet server" ... can you please explain how to do this? Thx
Rochinha
Posts: 309
Joined: Sun Jan 08, 2006 10:09 pm
Location: Brasil - Sao Paulo
Contact:

Post by Rochinha »

SteveLai,

First:

Download the application at:
http://www.xharbour.com/xhc/index.asp?p ... show_sub=1

- Open the ZIP File and extract the content to C:\WINDOWS\system32\inetsrv

- Open your Start Menu and go to Administrative Tools.
- Click in Internet Information Manager(IIS)
- Click in Web Extensions
- Click in Add New Extension

- Put XBS in Name Extension Field
Click in Add button and search the XBScript.dll in C:\WINDOWS\system32\inetsrv

- Allow Status Checkbox
- Click OK

See this video explanation:

http://www.5volution.com/forum/SteveLai.htm
Post Reply