ASP Tutorials
Update Records
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!-- #include file = "data_source.inc" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Edit</title>
</head>
<body>
<%
Dim my_connection, my_query, my_recordset
Dim my_database_source, quote_id
quote_id=request.querystring("quote_id")
my_query = "SELECT * FROM my_quotes WHERE quote_id=" & quote_id
set my_connection = Server.CreateObject("ADODB.Connection")
set my_recordset = Server.CreateObject("ADODB.Recordset")
my_connection.open (my_database_source)
my_recordset.open my_query, my_connection
%>
<div>
<form method="post" action="update.asp" name="form">
<input type="hidden" name="quote_id" value="<%= my_recordset("quote_id")%>">
<div>First Name:</div>
<div><input name="first_name" type="text" value="<%= my_recordset("first_name")%>" size="70"></div>
<div>Last Name:</div>
<div><input name="last_name" type="text" value="<%= my_recordset("last_name")%>" size="70"></div>
<div>Quote:</div>
<div><textarea name="quote" cols="50" rows='8'><%= my_recordset ("quote") %></textarea></div>
<div>Subject:</div>
<div><input type="text" name="subject" value="<%= my_recordset("subject")%>"></div>
<div><input type="submit" name="Submit" value="Submit"></div>
</form>
</div>
<%
my_recordset.close
set recordset = nothing
my_connection.close
set my_connection = nothing
%>
</body>
</html>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!-- #include file = "data_source.inc" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Update</title>
</head>
<body>
<%
Dim my_connection, my_query, my_recordset, my_database_source
Dim quote_id, first_name, last_name, quote, subject
quote_id = request.form("quote_id")
first_name = request.form("first_name")
last_name = request.form("last_name")
quote = request.form("quote")
subject = request.form("subject")
my_query = "UPDATE my_quotes SET first_name='" & first_name & "', last_name='" & last_name & "', quote='" & quote & "', subject='" & subject & "' WHERE quote_id=" & quote_id
set my_connection = Server.CreateObject("ADODB.Connection")
my_connection.open(my_database_source)
my_connection.execute(my_query)
my_connection.close
set my_connection = nothing
response.write "<div>Data has been updated successfully!</div>"
%>
</body>
</html>