VBSCript inside ASP page

P

pjglick

I am sorry if this sounds hokey but I am a newbie to ASP.



I have a VBScript running in an ASP page. The script makes a
connection to Oracle via and ADODB connection. When my clients connect
to the ASP page they get Oracle client issues. How do I make the
script run from the server side to eliminatew any oracle client issues
or oracle tns names issues.

Hope someone can help



Paul

Code



<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
<title>Untitled Document</title>
</head>

<body>
<div align="center"><img src="pics/banner_new.jpg" width="700"
height="80" /> <br />




<script type="text/vbscript">

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection2 =
CreateObject("ADODB.Connection")
Set objRecordset2 = CreateObject("ADODB.Recordset")

objConnection2.Open = "DRIVER={Microsoft ODBC for
Oracle}; SERVER=<removed>; UID=<removed>; PWD=<removed>"

strQuery1 = "SELECT TRUNC(log_date_time)
DAY,UPPER(SUBSTR(workstation,1,3)) WORKSTATION, COUNT(*) COUNT FROM
member_log WHERE logon_type='LOGON' GROUP BY
TRUNC(log_date_time),UPPER(SUBSTR(workstation,1,3))"
' strQuery1 = "Select * from member_log"



objRecordset2.Open strQuery1, _
objConnection2, adOpenStatic, adLockOptimistic


' If Not objRecordSet.EOF Then
'objRecordSet.MoveFirst

Do Until objRecordSet2.EOF



If Left(ObjRecordSet2("WORKSTATION"),3) = "W03"
Then
'document.write "WESTAMPTON" & vbTab &
(ObjRecordSet2("WORKSTATION")) & vbTab & (ObjRecordSet2("DAY")) & vbTab
& (ObjRecordSet2("COUNT"))
wh1= (ObjRecordSet2("Day")) & "&nbsp" & "&nbsp"
& "&nbsp" &"&nbsp" &"&nbsp" &"&nbsp" &"&nbsp"&"&nbsp"&"&nbsp"
&"&nbsp"&"&nbsp"&"&nbsp"& (ObjRecordSet2("COUNT")) & "<br>"
wh = wh + wh1
testw = CInt(ObjRecordSet2("COUNT"))
westh = westH + testw
Elseif Left(ObjRecordSet2("WORKSTATION"),3) = "W05" Then
testv = CInt(ObjRecordSet2("COUNT"))
vnld = vnld + testv
vn1= (ObjRecordSet2("Day")) & "&nbsp" & "&nbsp" & "&nbsp"
&"&nbsp" &"&nbsp" &"&nbsp" &"&nbsp"&"&nbsp"&"&nbsp"
&"&nbsp"&"&nbsp"&"&nbsp"& (ObjRecordSet2("COUNT")) & "<br>"
vn = vn + vn1

Elseif Left(ObjRecordSet2("WORKSTATION"),3) =
"W10" Then
testnb = CInt(ObjRecordSet2("COUNT"))
newb = newb + testnb
nb1= (ObjRecordSet2("Day")) & "&nbsp" & "&nbsp" & "&nbsp"
&"&nbsp" &"&nbsp" &"&nbsp" &"&nbsp"&"&nbsp"&"&nbsp"
&"&nbsp"&"&nbsp"&"&nbsp"& (ObjRecordSet2("COUNT")) & "<br>"
nb = nb + nb1
Elseif Left(ObjRecordSet2("WORKSTATION"),3) = "W05"
Then
testv = CInt(ObjRecordSet2("COUNT"))
vnld = vnld + testv
vn1= (ObjRecordSet2("Day")) & vbTab & (ObjRecordSet2("COUNT")) &
"<br>"
vn = vn + vn1


Elseif Left(ObjRecordSet2("WORKSTATION"),3) = "W12"
Then
testd = CInt(ObjRecordSet2("COUNT"))
dov = dov + testd
dv1= (ObjRecordSet2("Day")) & "&nbsp" & "&nbsp" & "&nbsp"
&"&nbsp" &"&nbsp" &"&nbsp" &"&nbsp"&"&nbsp"&"&nbsp"
&"&nbsp"&"&nbsp"&"&nbsp"& (ObjRecordSet2("COUNT")) & "<br>"
dv = dv + dv1





End If
objRecordset2.movenext
Loop
objRecordset2.Close
objConnection2.Close

document.write ""
document.write "WESTHAMPTON" & "<br>"
document.write "DATE"& "&nbsp" & "&nbsp" & "&nbsp"
&"&nbsp"&"&nbsp"&"&nbsp"&"&nbsp" &"&nbsp" &"&nbsp" &"&nbsp" & "COUNT"
& "<br>"
document.write wh
document.write "Total For WestHampton: " & westh & "<br>" & "<br>"
document.write ""
document.write "VINELAND" & "<br>"
document.write "DATE" & "&nbsp" & "&nbsp" & "&nbsp"
&"&nbsp"&"&nbsp"&"&nbsp"&"&nbsp" &"&nbsp" &"&nbsp" &"&nbsp" & "COUNT"
& "<br>"
document.write vn
document.write "Total for Vineland: " & vnld & "<br>" & "<br>"
document.write ""
document.write" NEW BRUNSWICK" & "<br>"
document.write "DATE" & "&nbsp" & "&nbsp" & "&nbsp"
&"&nbsp"&"&nbsp"&"&nbsp"&"&nbsp" &"&nbsp" &"&nbsp" &"&nbsp" & "COUNT"
& "<br>"
document.write nb
document.write "Total for New Brunswick: " & newb & "<br>" & "<br>"

document.write ""
document.write"DOVER" & "<br>"
document.write "DATE"& "&nbsp" & "&nbsp" & "&nbsp"
&"&nbsp"&"&nbsp"&"&nbsp"&"&nbsp" &"&nbsp" &"&nbsp" &"&nbsp" & "COUNT"
& "<br>"
document.write dv
document.write "Total for Dover: " & dov





</script>

</div>
<p align="center">&nbsp;</p>
</body>
</html>
 
R

Ray Costanzo [MVP]

Basically speaking, run that script server-side, and instead of
document.write, you use Response.Write.

Get rid of the "<script type="text/vbscript"> stuff. Use:

<%
'''code
%>

Or, you can use
<script type="text/vbscript" runat="server"></script>,
but it's more common to use <% and %> as it's shorthand for that (assuming
VBScript is the declared language for the page, or the default language in
your app, which it is by default).



Ray at work
 
P

pjglick

Thank you very much for replying

When I add the <script type="text/vbscript" runat="server"></script>

I get the following message.

The tag: "script" doesn't have an attribute: "runat" in currently
active versions. I am using IE6.

Any suggestions

Paul
 
R

Roland Hall

in message
: Thank you very much for replying

It was nothing. (O:=

: When I add the <script type="text/vbscript" runat="server"></script>
:
: I get the following message.
:
: The tag: "script" doesn't have an attribute: "runat" in currently
: active versions. I am using IE6.
:
: Any suggestions

Yes, use ASP tags instead of script tags as Ray suggested.

<%@ Language="VBScript" %>
<%
Option Explicit
Response.Buffer = True

' inline code
' global variables

' code goes here

sub someSub(someParameter)
' local variables
' code goes here
end sub

function someFunction(someParameter, someOtherParameter)
' local variables
' code goes here
someFunction = someValueOfSomeCalculationOfSomeLocalVariable
end function
%>

http://w3schools.com/asp/

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top