473,327 Members | 2,007 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

SQL statement help

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

Feb 12 '06 #1
0 1043

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert Mark Bram | last post by:
Hi All! I have the following two methods in an asp/jscript page - my problem is that without the update statement there is no error, but with the update statement I get the following error: ...
4
by: James E Koehler | last post by:
I can't get the WHILE statement to work in MySQL. The version of MySQL that I am using is: Ver 12.16 Distrib 4.0.6-gamma, for Win95/Win98 (i32) running on Windows MX. Here is the relevant...
2
by: Little PussyCat | last post by:
Hello, I hope you can help me. We have a SQL Server 2000 database at work, (which works with a VB6 frontend) which grew to a considerable size, so one of my past colleagues sent me this...
5
by: WindAndWaves | last post by:
Hi Team The function below searches all the tables in a database. However, if subsearch = true then it searches all the objects listed in a recordset (which are all table names). I thought to...
11
by: Scott C. Reynolds | last post by:
In VB6 you could do a SELECT CASE that would evaluate each case for truth and execute those statements, such as: SELECT CASE True case x > y: dosomestuff() case x = 5: dosomestuff() case y >...
10
by: John Smith | last post by:
Can you do a Select Statement within a Select Statement? I want to build a query similar to queries built in Access which link to other queries but using only SQL Statements. Is it possible? If...
6
by: FayeC | last post by:
I really need help figuring this out. i have a db with mostly text fields but 2. The user_id field is an autonumber (key) and the user_newsletter is a number (1 and 0) field meaning 1 yes the ...
4
by: Jack | last post by:
Hi, I have a asp page where part of the code is as follows. This builds up the sql statement partially. sql01 = "UPDATE EquipmentTbl SET " sql01 = sql01 & "SerialNumber = '" &...
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
18
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.