Simple query returns 0 records in asp, but all records in vbscript

Discussion in 'ASP General' started by masg0013@gmail.com, Nov 2, 2006.

  1. Guest

    I have a few vbscripts that I want to convert to asp pages so I can
    use html to format the data better.

    1). Do asp pages have to be run from an IIS server or can I just
    create them locally and then open them in IE?

    2) The following connection strings, accounts and queries work fine in
    vbs files but I am getting 0 results when I run them as asp. I don't
    know how to debug them to figure out the issue

    here is the code

    <%@ language="VBSCRIPT" %>
    <html>
    <head>
    <meta name="GENERATOR" content="SAPIEN Technologies PrimalScript 4.0">
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1">
    <title>CFG site</title>
    </head>
    <body>

    <%
    Dim objConnection, dsn
    Set objConnection = CreateObject("ADODB.Connection")
    objConnection.Open "Provider=SQLOLEDB;Data Source=servername;" & _
    "Trusted_Connection=Yes;Initial Catalog=edfcm4;" & _
    "User ID=user;Password=password;"
    Set rs=objConnection.Execute ("SELECT machine_name FROM
    ecm_dat_machines")
    %>
    <table border="1">
    <%
    Do While Not rs.EOF
    %>
    <tr>
    <td><%= rs.Fields("ecm_dat_machines.machine_name")%></td>
    </tr>
    <%
    rs.MoveNext
    Loop
    %>
    </table>
    <%
    Set objConnection = Nothing
    %>
    </body>
    </html>
     
    , Nov 2, 2006
    #1
    1. Advertising

  2. Mike Brind Guest

    <> wrote in message
    news:...
    >I have a few vbscripts that I want to convert to asp pages so I can
    > use html to format the data better.
    >
    > 1). Do asp pages have to be run from an IIS server or can I just
    > create them locally and then open them in IE?
    >
    > 2) The following connection strings, accounts and queries work fine in
    > vbs files but I am getting 0 results when I run them as asp. I don't
    > know how to debug them to figure out the issue
    >
    > here is the code
    >
    > <%@ language="VBSCRIPT" %>
    > <html>
    > <head>
    > <meta name="GENERATOR" content="SAPIEN Technologies PrimalScript 4.0">
    > <meta http-equiv="Content-Type" content="text/html;
    > charset=iso-8859-1">
    > <title>CFG site</title>
    > </head>
    > <body>
    >
    > <%
    > Dim objConnection, dsn
    > Set objConnection = CreateObject("ADODB.Connection")
    > objConnection.Open "Provider=SQLOLEDB;Data Source=servername;" & _
    > "Trusted_Connection=Yes;Initial Catalog=edfcm4;" & _
    > "User ID=user;Password=password;"
    > Set rs=objConnection.Execute ("SELECT machine_name FROM
    > ecm_dat_machines")
    > %>
    > <table border="1">
    > <%
    > Do While Not rs.EOF
    > %>
    > <tr>
    > <td><%= rs.Fields("ecm_dat_machines.machine_name")%></td>


    1. ASP pages must be run against an asp-enabled web server. If you have XP
    Pro, you can add IIS 5.1 by going to Control Panel -> Add Or Remove
    Programs - > Add/Remove Windows Components then ticking Internet Information
    Services. If you open them in the browser directly, they are not processed
    by the ASP engine, so the script will appear as text.

    2. Wrong syntax. Try <%=rs("machine_name")%>. Don't include the table
    name.

    Couple of other things: you declared a variable called dsn, but never used
    it. While you set the connection to nothing, you left the recordset alone.
    You should close that and set it to nothing once you're done with it, too
    (before finishing with the connection).

    --
    Mike Brind
     
    Mike Brind, Nov 2, 2006
    #2
    1. Advertising

  3. Evertjan. Guest

    wrote on 02 nov 2006 in microsoft.public.inetserver.asp.general:

    > 1). Do asp pages have to be run from an IIS server or can I just
    > create them locally and then open them in IE?


    ASP code only runs through the ASP interpretor, that converts output to a
    html stream that is sent to the requesting browser.

    Running an asp file in a browser will get you nowhere.

    > 2) The following connection strings, accounts and queries work fine in
    > vbs files but I am getting 0 results when I run them as asp.


    I strongly advice you against database handling trough ASP untill you have
    mastered the concepts of ASP and it's script languages.
    [Read the archive of this NG and the de facto faq http://www.aspfaq.com,
    and a simple asp tutorial perhaps]

    > I don't
    > know how to debug them to figure out the issue


    Basic debuging goes by inspecting error messages and putting

    response.write yourVariableToBeRead
    response.end

    [vbscript version] breakpoints in strategic places.


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Nov 2, 2006
    #3
  4. <> wrote in message
    news:...
    > I have a few vbscripts that I want to convert to asp pages so I can
    > use html to format the data better.
    >


    Doesn't sound like ASP is what you need.

    Continue to use VBS files. Research how to Automate IE to which you can
    write the HTML output of the VBS. Here's a start for 10:-

    Dim oIE : Set oIE = WScript.CreateObject("InternetExplorer.Application")

    oIE.menubar = false
    oIE.toolbar = false
    oIE.statusBar = false
    oIE.navigate "about:blank"
    oIE.visible = true

    Do While oIE.Busy
    WScript.sleep 100
    Loop

    Dim oDoc : Set oDoc = oIE.document

    oDoc.open
    oDoc.write "<html><body>Hello World</body></html>"
    oDoc.close


    For more advanced application you could consider creating a HTA.


    Anthony.
     
    Anthony Jones, Nov 2, 2006
    #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. M. Craig
    Replies:
    2
    Views:
    6,083
    M. Craig
    Nov 19, 2003
  2. KevinGPO

    QUERY: debugging ASP VBScript

    KevinGPO, Jan 23, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    2,464
    KevinGPO
    Jan 25, 2006
  3. KevinGPO

    QUERY: debugging ASP VBScript

    KevinGPO, Jan 23, 2006, in forum: ASP General
    Replies:
    4
    Views:
    154
    Anthony Jones
    Feb 6, 2006
  4. Srijayanth Sridhar
    Replies:
    19
    Views:
    624
    David A. Black
    Jul 2, 2008
  5. Andrew Poulos

    db query returns many records

    Andrew Poulos, Jul 9, 2007, in forum: Javascript
    Replies:
    0
    Views:
    134
    Andrew Poulos
    Jul 9, 2007
Loading...

Share This Page