Spanky
Spanky

Reputation: 709

How to update a record using SQL in ASP

So I'm trying to update a record within a table I created. The form processes but for some reason I don't see the table columns updated. The HTML form is

<form action="divProgramProcess.asp?div=<% =divrec %>" id="countInput" class="contact_form">

<input type="text"  name="Shipment_Current" id="Shipment_Current" value="<% =Shipment_Current %>" />
<input type="text"  name="Couch_Current" id="Couch_Current"  value="<%= Couch_Current %>" />
<input type="text"  name="Person_Available_Current" id="Person_Available_Current"  value="<%= Person_Available_Current %>" />
</form>

The code within divProgramProcess.asp is

<%
divrec = request.QueryString("div")
Set rstest = Server.CreateObject("ADODB.Recordset")
rstest.locktype = adLockOptimistic
sql = "SELECT top 1 * FROM CensusFacility_Records_Last WHERE Count = '1239' "
rstest.Open sql, db
%>


<body> 
<%
Shipment_Current = request.form("Shipment")
Couch_Current = request.form("Couch")
Person_Available_Current = request.form("Person_Available")

rstest("Shipment") = Shipment_Current
rstest("Couch") = Couch_Current
rstest("Person_Available") = Person_Available_Current
rstest.update
Response.Redirect("chooseScreen.asp")
%>

Upvotes: 0

Views: 1115

Answers (1)

AnonJr
AnonJr

Reputation: 2757

If you have some information you know you're going to pass, you may find it easier to just set it as a hidden input.

For example, instead of what you're doing above, do this with your form:

<form action="divProgramProcess.asp" id="countInput" class="contact_form">

<input type="text"  name="Shipment_Current" id="Shipment_Current" value="<% =Shipment_Current %>" />
<input type="text"  name="Couch_Current" id="Couch_Current"  value="<%= Couch_Current %>" />
<input type="text"  name="Person_Available_Current" id="Person_Available_Current"  value="<%= Person_Available_Current %>" />
<input type="hidden" name="div" value="<% =divrec %>" />
</form>

And pull the value of div from the Request.Form collection.

Upvotes: 1

Related Questions