I
isaac2004
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
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