473,739 Members | 7,912 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with SQL Insert and delete

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 .

here is the code i have so far
<% Option Explicit %>
<!--#include file="DatabaseC onnect2.asp"-->
<!--#include virtual="/06Winter/levini/database/adovbs.inc"-->
<html>
<head><title>Us ing 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="strFirstN ame" size="20">
</td>
</tr>
<tr>
<td>
Last Name:
</td>
<td>
<input type="textbox" name="strLastNa me" 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='#B BDBE6'>
<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.queryst ring("strFirstN ame")
strLastName = Request.queryst ring("strLastNa me")
'Create a recordset object and execute the SQL statement
Set objRS = Server.CreateOb ject("ADODB.Rec ordset")

strSQL = "SELECT tblNames.Person ID, tblNames.strFir stName,
tblNames.strLas tName " & _
"FROM tblNames " & _
"ORDER BY tblNames.Person ID "
objRS.Open strSQL, objConn
if request.queryst ring ("Add Name") > " " then

strSQL = "INSERT INTO tblNames (strFirstName, strLastName) " & _
"VALUES (CleanIn)('strF irstName')('str LastName')"

objRS.Open strSQL, objConn
end if

response.write( "<TR><TD>" & objRS("PersonID ") & "</TD>")
response.write( "<TD>" & objRS("strFirst Name") & "</TD>")
response.write( "<TD>" & objRS("strLastN ame") & "</TD>")
response.write( "<TD><a href='SQLInsert Delete.asp?Dele teID=" &
objRS("PersonID ") & "'>Delete</a></TD></table>")

response.write "strSQL=" & strSQL & "<br>"
%>

</body>
</html>

Feb 13 '06 #1
0 1355

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

Similar topics

2
2040
by: dinks | last post by:
Hi, I'm new to C++ and have been assigned a task which i dont completely understand. Any help would be greately appreciated. Here is the problem: The class "linkedListType" use the "assert" facility. I am to get rid of them and replace them with exceptions. I need to create a "linkedListException" class that's declared and implemented in my "linkedListType" class. This class needs to inherit from the base "exception" class and return...
7
2391
by: Alan Bashy | last post by:
Please, guys, In need help with this. It is due in the next week. Please, help me to implement the functions in this programm especially the first three constructor. I need them guys. Please, help me. This was inspired by Exercise 7 and Programming Problem 8 in Chapter 3 of our text. I have done Exercise 7 for you: Below you will find the ADT specification for a string of characters. It represents slightly more that a minimal string...
5
2111
by: jhon02148 | last post by:
hi this hw have four files: 1. for the main program 2. listp.cpp (the source file) 3. listp.h (the header file) 4. exception.h if there is anybody who could help me with this hw i really appreciate his help. thanks for anybody in advance
28
3303
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical make-believe challenge in order to avoid confusing the issue further. Suppose I was hosting a dinner and I wanted to invite exactly 12 guests from my neighborhood. I'm really picky about that... I have 12 chairs besides my own, and I want them all...
4
3130
by: Big D | last post by:
Hi all, I'm trying to understand the best way to use a try catch with a SQL transaction. I have a number of sql statements that need to be run, such as: 'open sqlConnection, get command object, etc. myTrans.BeginTransaction() 'do a delete 'do a update
3
3450
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all the necessary records in it when testing it. I get the error "No value given for one or more required parameters." when I try to update the database. Can you tell me what am I doing wrong?
6
2429
by: Rylios | last post by:
I am trying to make a very basic text editor using a linked list, fstream, sorting... This is what i have so far ------------------------------------------------------------------------------------------------------------------------------------ The Linked.H --- Header file #include <iostream> using namespace std;
5
3789
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public List<RoleData> GetRoles() { return GetRoles(null, false); }
1
1173
by: TanmayQuery | last post by:
I have written a sql procedure, i want to pass delared variable @cnt in line131,char24 below is the PL Code: CREATE PROCEDURE PL @dt varchar(10), @stock as bit --1/true for updated and 0/false for previous executed data AS set dateformat dmy set nocount on
0
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9479
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9266
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8215
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6054
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3280
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.