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

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

Postby RAMESHBABU » Fri May 30, 2008 9: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


Code: Select all  Expand view  RUN
<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: 625
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Re: How to Open a DBF file from Internet Web Server via xBSc

Postby Enrico Maria Giordano » Fri May 30, 2008 10:02 am

Try

Code: Select all  Expand view  RUN
SET DEFAULT TO ( CURDRIVE() + ":\" + CURDIR() )


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby RAMESHBABU » Fri May 30, 2008 2: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
User avatar
RAMESHBABU
 
Posts: 625
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Postby Gale FORd » Fri May 30, 2008 3:44 pm

Are you running the script on server side? Try this

cDataPath := Request:ServerVariables["PATH_TRANSLATED"]:item()
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Postby Enrico Maria Giordano » Fri May 30, 2008 3:47 pm

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby RAMESHBABU » Sat May 31, 2008 2: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:

Code: Select all  Expand view  RUN
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  Expand view  RUN
<%@ 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
RAMESHBABU
 
Posts: 625
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Postby Enrico Maria Giordano » Sat May 31, 2008 9:43 am

All my scripts work fine using

Code: Select all  Expand view  RUN
SET DEFAULT TO ( CURDRIVE() + ":\" + CURDIR() )


But you have to run them server side.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby RAMESHBABU » Sun Jun 01, 2008 2:03 am

Hi Mr.Enrico

Can please give me a working sample asp file.

Regards,

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

Postby RAMESHBABU » Sun Jun 01, 2008 3:32 am

Mr.Enrico and Mr.Gale

Code: Select all  Expand view  RUN
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
RAMESHBABU
 
Posts: 625
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Postby Enrico Maria Giordano » Sun Jun 01, 2008 3: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

Code: Select all  Expand view  RUN
SET DEFAULT TO ( Server:MapPath( "./" ) )


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

xbscript.dll

Postby SteveLai » Tue Jun 24, 2008 2:52 pm

"I have registered the Xbscript.dll the internet server" ... can you please explain how to do this? Thx
User avatar
SteveLai
 
Posts: 11
Joined: Tue Apr 18, 2006 11:43 am
Location: Scotland

Postby Rochinha » Fri Jun 27, 2008 3: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
Rochinha
 
Posts: 310
Joined: Sun Jan 08, 2006 10:09 pm
Location: Brasil - Sao Paulo


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 61 guests