如何在ASP中使用SQL更新记录

时间:2013-08-22 16:46:15

标签: sql asp-classic

所以我正在尝试更新我创建的表中的记录。表单进程但由于某种原因我没有看到表列更新。 HTML表单是

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

divProgramProcess.asp中的代码是

<%
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")
%>

1 个答案:

答案 0 :(得分:1)

如果你知道自己要传递的信息,你可能会发现将其设置为隐藏输入更容易。

例如,不要使用上面的内容,而是使用表单执行此操作:

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

div集合中提取Request.Form的值。