SQL statement help

Discussion in 'ASP General' started by isaac2004, Feb 12, 2006.

  1. isaac2004

    isaac2004 Guest

    hello

    im trying to make a page that reads simple user information and posts
    them to a table. the user can edit, delete and add new records, through
    a form on the page.using SQLs modifications like insert and delete, how
    would you go about doing this. the script executes an if then statment
    that tests a submit button and initiates the insert portion of the SQL
    statement .

    the code i have throws an error stating that
    Item cannot be found in the collection corresponding to the requested
    name or ordinal
    doesnt this mean that i am trying to source something that is not part
    of the database.

    this is the code ive gotten so far

    <% Option Explicit %>
    <!--#include file="DatabaseConnect2.asp"-->
    <!--#include virtual="/06Winter/levini/database/adovbs.inc"-->
    <html>
    <head><title>Using SQL to List, Insert & Delete Data</title></head>
    <body>
    <center>
    <h3>Using SQL to List, Insert & Delete Data</h3>
    Please enter a name:
    <form>
    <table>
    <tr>
    <td>
    First Name:
    </td>
    <td>
    <input type="textbox" name="strFirstName" size="20">
    </td>
    </tr>
    <tr>
    <td>
    Last Name:
    </td>
    <td>
    <input type="textbox" name="strLastName" size="20">
    <input type="submit" Name="AddName" text="Add Name"
    Value="Add Person">
    </td>
    </tr>
    </table>
    </form>


    <table border='1' cellpadding='3' cellspacing='0'
    bordercolor='#BBDBE6'>
    <tr>
    <td><b>ID</b></td>
    <td><b>First Name</b></td>
    <td><b>Last Name</b></td>
    <td><b>Delete</b></td>
    </tr>



    <%
    dim objRS, strSQL, strLastName, strFirstName

    function CleanIn(strIn)
    strIn = replace(strIn, "'", " ")
    CleanIn = replace(strIn, "<", " ")
    end function


    strFirstName = Request.querystring("strFirstName")
    strLastName = Request.querystring("strLastName")


    'Create a recordset object and execute the SQL statement
    Set objRS = Server.CreateObject("ADODB.Recordset")

    strSQL = "SELECT tblNames.PersonID, tblNames.strFirstName,
    tblNames.strLastName " & _
    "FROM tblNames " & _
    "ORDER BY tblNames.PersonID "

    if request.querystring ("Add Name") > " " then

    strSQL = "SELECT tblNames.PersonID, tblNames.strFirstName,
    tblNames.strLastName " & _
    "FROM tblNames " & _
    "ORDER BY tblNames.PersonID " & _
    "INSERT INTO tblNames (strFirstName, strLastName) " & _
    "VALUES (CleanIn('strFirstName')('strLastName')"


    objRS.Open strSQL, objConn, 3
    end if

    %>
    <TR>
    -----------------------------part that error is thrown
    <TD><% =objRS("PersonID") %> </TD>
    ----------------------------------------------------------------------
    <TD><% =objRS("strFirstName") %> </TD>
    <TD><% =objRS("strLastName") %> </TD>
    <TD><a href="SQLInsertDelete.asp?DeleteID=<%= objRS("PersonID")
    %>">Delete</a></TD>
    </table>
    <%
    response.write "strSQL=" & strSQL & "<br>"
    %>

    </body>
    </html>


    does anyone have any advice how to get this page up and runnin. thank
    you
    isaac2004, Feb 12, 2006
    #1
    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. dna
    Replies:
    1
    Views:
    1,264
  2. William \(Bill\) Vaughn
    Replies:
    0
    Views:
    437
    William \(Bill\) Vaughn
    Aug 21, 2003
  3. David Browne
    Replies:
    0
    Views:
    448
    David Browne
    Aug 21, 2003
  4. ecoolone
    Replies:
    0
    Views:
    745
    ecoolone
    Jan 3, 2008
  5. weiwei

    asp and sql statement in sql server db

    weiwei, Sep 22, 2004, in forum: ASP General
    Replies:
    3
    Views:
    198
    Jeff Cochran
    Sep 22, 2004
Loading...

Share This Page