Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update multiple records

Status
Not open for further replies.

taoist

Programmer
Joined
Feb 1, 2006
Messages
35
Location
US
I have this code, and I trying to update records, but when I hit the submit button it does not save the changes

is there anyone out there that could help me


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../../../../../../Connections/cnnDB.asp" -->
<%

if(Request.QueryString("grd") <> "") then update__param_grade = Request.QueryString("grd")

if(Request.QueryString("chk") <> "") then update__param_index = Request.QueryString("chk")

%>
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("str") <> "") Then
Recordset1__MMColParam = Request.QueryString("str")
End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_cnnDB_STRING
Recordset1.Source = "SELECT * FROM dbo.eval_master WHERE CRN = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%

set update = Server.CreateObject("ADODB.Command")
update.ActiveConnection = MM_cnnDB_STRING
update.CommandText = "UPDATE dbo.eval_master SET GRADE = '" + Replace(update__param_grade, "'", "''") + "' WHERE INDEX1 IN ('" + Replace(update__param_index, "'", "''") + "') "
update.CommandType = 1
update.CommandTimeout = 0
update.Prepared = true
update.Execute()
set update = nothing
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="get" action="">
<label>
<input name="str" type="text" id="str" />
</label>
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</form>
<form id="form2" name="form2" method="post" action="">
<% If Not Recordset1.EOF Or Not Recordset1.BOF Then %>
<table width="415" border="1">
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<tr>
<td width="163"><label>
<input name="chk" type="text" id="chk" value="<%=(Recordset1.Fields.Item("INDEX1").Value)%>" />
</label></td>
<td width="163" height="39"><%=(Recordset1.Fields.Item("LAST").Value)%></td>
<td width="67"><label>
<select name="grd" id="grd" title="<%=(Recordset1.Fields.Item("GRADE").Value)%>">
<option>*</option>
<option>A</option>
<option>B</option>
<option>C</option>
<option>D</option>
</select>
</label></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
</table>
<% End If ' end Not Recordset1.EOF Or NOT Recordset1.BOF %>
<p>
<label></label>
</p>
<p>
<label>
<input type="submit" name="Submit2" value="Submit" />
</label>
</p>
</form>
<p>&nbsp;</p>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
 
Can you let us know how it's NOT doing what you want?





General FAQ faq333-2924
5 steps to asking a question faq333-3811
 
well its not doing anything.

I want to save changes on multiple records thats created by the recordset.

hitting the submit button does not produce an error. so
I'm not sure what the problem is.
 
posting the complete code does not provide you solutions...its very hard for us to even what you are trying to do...

i would suggest doing respons.write at various places in your code for debugging purposes and see if there is something suspicious...

-DNG
 
I'm not sure if the structure of the update code is correct
 
So put a
Code:
Response.Write update.CommandText
immediately after you construct it, and before you use itt

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
I'm getting this with the response.write

UPDATE dbo.eval_master SET GRADE = '' WHERE INDEX1 IN ('')
 
So that at least tells you something.... update__param_grade and update__param_index are empty.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top