#1
  1. No Profile Picture
    Contributing User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2011
    Posts
    32
    Rep Power
    4

    Creating a Table at the click of a button with classic asp


    Hello,

    I need the help of an expert here on this forum.

    I am trying to validate information, without switching the page (in this case a username, if the username is found, great, populate a textbox and dynamically create a table with the username it it). However, I am getting an error on line 75 that reads:

    Code:
    ADODB.Recordset
    
     error '800a0e78' 
    
    Operation is not allowed when the object is closed. 
    
    /login.asp, line 75
    I haven't closed the recordset anywhere. By my knowledge it should work. What am I doing wrong?

    Code:
    <%
    Dim cn,rs
        Set cn = Server.CreateObject("ADODB.Connection")
        Set rs = Server.CreateObject("ADODB.recordset")
    
        cn.Provider = "Microsoft.Jet.OLEDB.4.0"
    
        cn.Open Server.MapPath("login.mdb")
    
    'Default message for the user on the login page
    msg = "Please login"
    
    'Logout code. This code empties the session variable which holds the user's userID.
    If Request.QueryString("action") = "logout" Then
        Session("user_id") = ""
        msg = "You have been logged out"
    End If
    
    
    'Check if the form has been submitted
    
    If Request.Form("Submit") = "Test" Then
    
        user_name = Request.Form("user_name")
        user_pass = Request.Form("user_pass")
    
        mySQL = "SELECT user_id, user_name, user_pass FROM users WHERE user_name = '" & user_name & "' AND user_pass = '" & user_pass & "'"
    
        'Select the data from the database using the submitted data.
        rs.Open mySQL, cn
    
            'Check if a match was found.
            If NOT rs.EOF Then
    
                'Session("user_id") = rsLogin("user_id")
                'Response.Redirect("profile.asp")
    
                u = rs("user_name")
    
            Else
                'If a match was not found then output an error.
                Response.Redirect("login.asp?errmsg=Login failed")
            End If
    End If
    %>
    
    
    
    <!DOCTYPE html>
    <html>
    <head>
    </head>
    
    <body>
    <form name="form1" id="form1" method="post" action="">
      <table width="300" border="0" cellspacing="0" cellpadding="2">
        <tr>
          <td>Username</td>
          <td><input name="user_name" type="text" id="user_name" /></td>
        </tr>
        <tr>
          <td>Password</td>
          <td><input name="user_pass" type="password" id="user_pass" /></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><input type="submit" name="Submit" value="Test" /></td>
        </tr>
      </table>
    </form>
    <input id="fileno" value="<%=u%>" type="text">
    
    
    <%
            While NOT rs.EOF
    %>
        <table width="200" border="1" cellspacing="0" cellpadding="2">
      <tr>
        <th scope="col"><div align="left">username</div></th>
      </tr>
    
      <tr>
        <td><%=u%></td>
      </tr>
    <%
            rs.MoveNext
            Wend
    %>
    </table>
    </body>
    </html>
  2. #2
  3. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,594
    Rep Power
    278
    Originally Posted by jason_kelly
    Hello,

    I need the help of an expert here on this forum.

    I am trying to validate information, without switching the page (in this case a username, if the username is found, great, populate a textbox and dynamically create a table with the username it it). However, I am getting an error on line 75 that reads:

    Code:
    ADODB.Recordset
    
     error '800a0e78' 
    
    Operation is not allowed when the object is closed. 
    
    /login.asp, line 75
    I haven't closed the recordset anywhere. By my knowledge it should work. What am I doing wrong?

    Code:
    <%
    Dim cn,rs
        Set cn = Server.CreateObject("ADODB.Connection")
        Set rs = Server.CreateObject("ADODB.recordset")
    
        cn.Provider = "Microsoft.Jet.OLEDB.4.0"
    
        cn.Open Server.MapPath("login.mdb")
    
    'Default message for the user on the login page
    msg = "Please login"
    
    'Logout code. This code empties the session variable which holds the user's userID.
    If Request.QueryString("action") = "logout" Then
        Session("user_id") = ""
        msg = "You have been logged out"
    End If
    
    
    'Check if the form has been submitted
    
    If Request.Form("Submit") = "Test" Then
    
        user_name = Request.Form("user_name")
        user_pass = Request.Form("user_pass")
    
        mySQL = "SELECT user_id, user_name, user_pass FROM users WHERE user_name = '" & user_name & "' AND user_pass = '" & user_pass & "'"
    
        'Select the data from the database using the submitted data.
        rs.Open mySQL, cn
    
            'Check if a match was found.
            If NOT rs.EOF Then
    
                'Session("user_id") = rsLogin("user_id")
                'Response.Redirect("profile.asp")
    
                u = rs("user_name")
    
            Else
                'If a match was not found then output an error.
                Response.Redirect("login.asp?errmsg=Login failed")
            End If
    End If
    %>
    
    
    
    <!DOCTYPE html>
    <html>
    <head>
    </head>
    
    <body>
    <form name="form1" id="form1" method="post" action="">
      <table width="300" border="0" cellspacing="0" cellpadding="2">
        <tr>
          <td>Username</td>
          <td><input name="user_name" type="text" id="user_name" /></td>
        </tr>
        <tr>
          <td>Password</td>
          <td><input name="user_pass" type="password" id="user_pass" /></td>
        </tr>
        <tr>
          <td>*</td>
          <td><input type="submit" name="Submit" value="Test" /></td>
        </tr>
      </table>
    </form>
    <input id="fileno" value="<%=u%>" type="text">
    
    
    <%
    If Request.Form("Submit") = "Test" Then
            While NOT rs.EOF
    %>
        <table width="200" border="1" cellspacing="0" cellpadding="2">
      <tr>
        <th scope="col"><div align="left">username</div></th>
      </tr>
    
      <tr>
        <td><%=u%></td>
      </tr>
    <%
            rs.MoveNext
            Wend
    end if
    %>
    </table>
    </body>
    </html>
    Your code does not make a lot of sense, but when you open page for first time you
    If Request.Form("Submit") = "Test" is false, so you do not open any recordsets...
    but you have While NOT rs.EOF where you should have error, Add if statement like I inserted in your code in red and it will work
    GK
    __________________________________________________ _____
    if you found this post is useful click Give Rep button (bottom side on this reply ) and agree

Similar Threads

  1. Replies: 5
    Last Post: May 18th, 2010, 04:45 PM
  2. c#: button.click event doesn't occur at click
    By Timo in forum .NET Development
    Replies: 14
    Last Post: November 19th, 2004, 12:29 PM
  3. Replies: 3
    Last Post: October 20th, 2004, 03:46 AM
  4. Howto populate a table with db datas when click a button?
    By zwonimir in forum ASP Development
    Replies: 4
    Last Post: May 20th, 2004, 09:57 AM
  5. Difference between Submit button-click & Refresh-click
    By Steve Schofield in forum ASP Development
    Replies: 0
    Last Post: May 18th, 2000, 07:12 AM

IMN logo majestic logo threadwatch logo seochat tools logo