VBSCript inside ASP page

Discussion in 'ASP General' started by pjglick, Nov 3, 2005.

  1. pjglick

    pjglick Guest

    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>
    pjglick, Nov 3, 2005
    #1
    1. Advertising

  2. 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

    "pjglick" <> wrote in message
    news:...
    > 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>
    >
    Ray Costanzo [MVP], Nov 3, 2005
    #2
    1. Advertising

  3. pjglick

    pjglick Guest

    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
    pjglick, Nov 3, 2005
    #3
  4. pjglick

    Roland Hall Guest

    "pjglick" wrote in message
    news:...
    : 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
    Roland Hall, Nov 4, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ChucRock
    Replies:
    2
    Views:
    5,804
    Lucas Tam
    Apr 16, 2005
  2. Jacques Koorts

    running ASP inside VBscript

    Jacques Koorts, May 2, 2004, in forum: HTML
    Replies:
    22
    Views:
    1,041
    Aaron Bertrand - MVP
    May 4, 2004
  3. BooGhost
    Replies:
    0
    Views:
    365
    BooGhost
    Aug 8, 2008
  4. Joe
    Replies:
    2
    Views:
    393
    Martin Honnen
    Apr 25, 2009
  5. luu duong
    Replies:
    2
    Views:
    329
    luu duong
    Oct 8, 2003
Loading...

Share This Page