FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to Open a DBF file from Internet Web Server via xBScript
Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM
How to Open a DBF file from Internet Web Server via xBScript
Posted: Fri May 30, 2008 09:47 AM
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


<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>
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: How to Open a DBF file from Internet Web Server via xBSc
Posted: Fri May 30, 2008 10:02 AM
Try

SET DEFAULT TO ( CURDRIVE() + ":\" + CURDIR() )


EMG
Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM
How to Open a DBF file from Internet Web Server via xBScript
Posted: Fri May 30, 2008 02:22 PM

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
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
How to Open a DBF file from Internet Web Server via xBScript
Posted: Fri May 30, 2008 03:44 PM

Are you running the script on server side? Try this

cDataPath := Request:ServerVariables["PATH_TRANSLATED"]:item()

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
How to Open a DBF file from Internet Web Server via xBScript
Posted: Fri May 30, 2008 03:47 PM

I agree with Gale: you probably run the script client side.

EMG

Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM
How to Open a DBF file from Internet Web Server via xBScript
Posted: Sat May 31, 2008 02:47 AM
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:

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.

<%@ 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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
How to Open a DBF file from Internet Web Server via xBScript
Posted: Sat May 31, 2008 09:43 AM
All my scripts work fine using

SET DEFAULT TO ( CURDRIVE() + ":\" + CURDIR() )


But you have to run them server side.

EMG
Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM
How to Open a DBF file from Internet Web Server via xBScript
Posted: Sun Jun 01, 2008 02:03 AM

Hi Mr.Enrico

Can please give me a working sample asp file.

Regards,

  • Ramesh Babu P
Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM
How to Open a DBF file from Internet Web Server via xBScript
Posted: Sun Jun 01, 2008 03:32 AM
Mr.Enrico and Mr.Gale

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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
How to Open a DBF file from Internet Web Server via xBScript
Posted: Sun Jun 01, 2008 03:34 PM
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

SET DEFAULT TO ( Server:MapPath( "./" ) )


EMG
Posts: 11
Joined: Tue Apr 18, 2006 11:43 AM
xbscript.dll
Posted: Tue Jun 24, 2008 02:52 PM

"I have registered the Xbscript.dll the internet server" ... can you please explain how to do this? Thx

Posts: 310
Joined: Sun Jan 08, 2006 10:09 PM
How to Open a DBF file from Internet Web Server via xBScript
Posted: Fri Jun 27, 2008 03:27 PM

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

Continue the discussion