Forums
This topic is locked
update more than 1 record at a time using checkbox
Posted 19 Jul 2007 14:32:33
1
has voted
19 Jul 2007 14:32:33 bill charrette posted:
Dreamweaver 8.0.2 - Language ASP – VBScriptI’m trying to update more than one record at a time using checkboxes. I’ve successfully done this numerous times prior to Dreamweaver 8.0.2.
Before Dreamweaver 8.0.2, I would create a page with a recordset, form, checkbox and repeat region and pass the ID to another page containing an ‘Update Command’. The code on the Update page looked similar to the following:
if(Request.QueryString("MemberID" <> "" then spMemberApproving__MMColParam = Request.QueryString("MemberID"
set spMemberApproving = Server.CreateObject("ADODB.Command"
spMemberApproving.ActiveConnection = MM_connIssuesManager_STRING
spMemberApproving.CommandText = "UPDATE tblMembers SET MemberApproved = 1 WHERE MemberID IN (" Replace(spMemberApproving__MMColParam, "'", "''" ""
spMemberApproving.CommandType = 1
spMemberApproving.CommandTimeout = 0
spMemberApproving.Prepared = true
spMemberApproving.Execute()
Response.Redirect("default.asp"
However, in Dreamweaver 8.0.2 when you fill out the Update Command dialog box, Dreamweaver asks you to provide the ‘Type’ and ‘Size’ for the variables (see: www.adobe.com/cfusion/knowledgebase/index.cfm?id=4e6b330a ).
That being said and done, the code on the Update page looks like the following:
IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
If condition = "" Then
MM_IIf = ifFalse
Else
MM_IIf = ifTrue
End If
End Function
if(Request.QueryString("MemberID" <> "" then spMemberApproving__MMColParam = Request.QueryString("MemberID"
Set spMemberApproving = Server.CreateObject ("ADODB.Command"
spMemberApproving.ActiveConnection = MM_connIssuesManager_STRING
spMemberApproving.CommandText = "UPDATE tblMembers SET MemberApproved = 1 WHERE MemberID IN (?) "
spMemberApproving.Parameters.Append spMemberApproving.CreateParameter("MMColParam", 202, 1, 10, MM_IIF(Request.QueryString("MemberID", Request.QueryString("MemberID", spMemberApproving__MMColParam & "")
spMemberApproving.CommandType = 1
spMemberApproving.CommandTimeout = 0
spMemberApproving.Prepared = true
spMemberApproving.Execute()
Response.Redirect("default.asp"
The Update Command works perfectly when only 1 record is being updated. However, when I try to update more than one record I get the following error:
Error Type:
ADODB.Command (0x800A0D5D)
Application uses a value of the wrong type for the current operation.
/issues_manager/admin/members_approving.asp, line 27
Can anyone help me out?
Replies
Replied 28 Sep 2007 07:06:37
28 Sep 2007 07:06:37 Ken Ryan replied:
Did you ever figure this out? I am having somwhat of the same problem.
Ken Ryan
Ken Ryan
Replied 14 Oct 2007 17:26:28
14 Oct 2007 17:26:28 bill charrette replied:
This is how I dealt with the issue of updating more than one record at a time using check boxes in Dreamweaver 8.0.2 (one of many
options I'm sure).
The code on the separate page containing the ‘Update Command’ looks like this:
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
If condition = "" Then
MM_IIf = ifFalse
Else
MM_IIf = ifTrue
End If
End Function
%>
<%
If(Request.Form("MemberID" <> "" Then spMemberApproving__MMColParam = Request.Form("MemberID"
%>
<%
' The following code is added to the Command Server Behavior to update more than one record at a time
AllMembers = Split(spMemberApproving__MMColParam, ","
for currentID=0 to UBound(AllMembers) 'convert ID list from html server to asp array.
' to access each array element use MemberID(currentID)
%>
<%
Set spMemberApproving = Server.CreateObject ("ADODB.Command"
spMemberApproving.ActiveConnection = MM_PerformanceManagement_STRING
spMemberApproving.CommandText = "UPDATE tblContractualDocs SET ContractualDocStatus = 1, ContractualDocSavingsNotificationDate =
Date() WHERE MemberID = ? "
spMemberApproving.Parameters.Append spMemberApproving.CreateParameter("MMColParam", 202, 1, 10, MM_IIF(AllMembers(currentID),
AllMembers(currentID), spMemberApproving__MMColParam & "")
spMemberApproving.CommandType = 1
spMemberApproving.CommandTimeout = 0
spMemberApproving.Prepared = true
spMemberApproving.Execute()
%>
<%
' The following code is added to the Command Server Behavior to update more than one record at a time
next ' increment for loop currentID variable
%>
<%
' The following code is added to the Command Server Behavior to update more than one record at a time
next ' increment for loop currentID variable
%>
options I'm sure).
The code on the separate page containing the ‘Update Command’ looks like this:
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
If condition = "" Then
MM_IIf = ifFalse
Else
MM_IIf = ifTrue
End If
End Function
%>
<%
If(Request.Form("MemberID" <> "" Then spMemberApproving__MMColParam = Request.Form("MemberID"
%>
<%
' The following code is added to the Command Server Behavior to update more than one record at a time
AllMembers = Split(spMemberApproving__MMColParam, ","
for currentID=0 to UBound(AllMembers) 'convert ID list from html server to asp array.
' to access each array element use MemberID(currentID)
%>
<%
Set spMemberApproving = Server.CreateObject ("ADODB.Command"
spMemberApproving.ActiveConnection = MM_PerformanceManagement_STRING
spMemberApproving.CommandText = "UPDATE tblContractualDocs SET ContractualDocStatus = 1, ContractualDocSavingsNotificationDate =
Date() WHERE MemberID = ? "
spMemberApproving.Parameters.Append spMemberApproving.CreateParameter("MMColParam", 202, 1, 10, MM_IIF(AllMembers(currentID),
AllMembers(currentID), spMemberApproving__MMColParam & "")
spMemberApproving.CommandType = 1
spMemberApproving.CommandTimeout = 0
spMemberApproving.Prepared = true
spMemberApproving.Execute()
%>
<%
' The following code is added to the Command Server Behavior to update more than one record at a time
next ' increment for loop currentID variable
%>
<%
' The following code is added to the Command Server Behavior to update more than one record at a time
next ' increment for loop currentID variable
%>