Updating multiple records at once - 3/30/2001 16:22:00
Hello, I have a script that I wrote to update multiple records at once (I know it is not recommended, but I really need to have it this way for convience of the users). The problem I am having is that it will update the first record, but not the 2nd, it appears everything is correct in the code, but it is not working correctly. When I pull the ID of the record into the 2nd field I have it named argid, but have told the code that argid = id when updating. Here is the multi-part code: <% user=request.querystring("user") 'Declare variables needed Dim strSQL Dim adCmdText 'Set required variables adCmdText = 1 '*********************************************************** '* Step 1: Display a list of boat class names to select from '*********************************************************** If Len(Request.Form("FormAction")) = 0 Then 'Create the recordset object Set objRS = Server.CreateObject("ADODB.Recordset") 'Open the recordset getting a list of all boat classes objRS.Open "Select Distinct wedate from everyone'","DSN=offstats" 'Response.write objRS("user") & "<BR>" %> <form action=Ex.asp method=post name=frmDisplay> <input type=hidden name=FormAction value=Step2> <table> <tr> <td colspan=2>Select a we date to update</td> </tr> <tr> <td>WE Date</td> <td><select name=cbowedate> <% 'Loop through the recordset adding class name to the combo box Do While Not objRS.EOF %> <option value="<%=objRS("wedate")%>"> <%=objRS("wedate")%></option> <% objRS.MoveNext Loop 'Close and dereference database objects objRS.Close Set objRS = Nothing %> </select>EDSNET ID <input NAME="user" VALUE="<%=Request.ServerVariables("REMOTE_USER")%>" size="20"></td> </tr> <tr> <td height=60><input type=submit name=btnSubmit value=Submit></td> </tr> </table> </form> <% '*********************************************************** '* Step 2: Display the update form '*********************************************************** ElseIf Request.Form("FormAction") = "Step2" Then 'Build the SQL string strSQL = "Select * from Everyone where wedate = '" & _ CStr(Request.Form("cbowedate")) & "'" 'Create the recordset object Set objRS = Server.CreateObject("ADODB.Recordset") 'Open the recordset getting the boat class details objRS.Open strSQL,"DSN=offstats" %> <form action=update2.asp method=post name=frmUpdate> <% 'Loop through the recordset adding class name to the combo box 'Do While Not objRS.EOF %> <input type=hidden name=txtClassName value="<%=objRS("Account")%>"><input type=hidden name=FormAction value=Step3> <p> ID <input type="text" name="ID" size="20" value="<%=objRS("id")%>"> </p> <p> Account <input type=text name=account size=30 value=<%=objRS("account")%>> </p> <p> EDSNET <input NAME="edsnet" VALUE="<%=Request.ServerVariables("REMOTE_USER")%>" size="20"> </p> <table height="334"> <tr> <td nowrap height="21">Allison Cust</td> <td height="21"><input type="text" name="aecust" size="20" value="<%=objRS("cust")%>"></td> </tr> <tr> <td nowrap height="25">Allison SN</td> <td height="25"><input type=text name=aesn size=5 value=<%=objRS("sn")%>></td> </tr> <tr> <td nowrap height="25">SA</td> <td height="25"><input type=text name=aesa size=5 value=<%=objRS("sa")%>></td> </tr> <tr> <td nowrap height="25">SE</td> <td height="25"><input type=text name=aese size=5 value=<%=objRS("se")%>></td> </tr> <tr> <td nowrap height="25">Misc</td> <td height="25"><input type=text name=aemisc size=5 value=<%=objRS("misc")%>></td> </tr> <tr> <td height="25">Undisp</td> <td height="25"><input type=text name=aeundisp size=30 value=<%=objRS("undisp")%>></td> </tr> <tr> <td height="21">Report</td> <td height="21"><input type=text name=aereport size=30 value=<%=objRS("report")%>></td> </tr> <tr> <td height="21">FYI</td> <td height="21"><input type=text name=aefyi size=30 value=<%=objRS("fyi")%>></td> </tr> </table> <% objRS.MoveNext 'Loop 'Close and dereference database objects 'objRS.Close 'Set objRS = Nothing 'End If %> ID <input type="text" name="argid" size="20" value="<%=objRS("id")%>"> <p>Account <input type=text name=argaccount size=30 value=<%=objRS("account")%>> </p> <p>ARG Cust <input type="text" name="argcust" size="20" value="<%=objRS("cust")%>"> </p> <p>ARG SN <input type="text" name="argsn" size="20" value="<%=objRS("sn")%>"> </p> <p><input type="submit" value="Submit" name="Submit"> <br> <% End If %> </p> </form> --------------------------- Here is the error message I am getting: Record is now updated! Your update is shown below UPDATE Everyone SET account='Allison',edsnet='VMCWEB\rzm41v',cust='111',sn='221',sa='331',se='441',misc='551',undisp='661',report='771',fyi='881' WHERE ID=516Database Errors Occured UPDATE Everyone SET argcust='201',argsn='191' WHERE ID=517 Error #-2147217904 Error desc. -> [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2. ------------------ Any help is apprecited! Thanks!
|