close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Multiple Update of SOME records

Thread began 2/03/2011 3:28 pm by ccooper309155 | Last modified 2/08/2011 6:40 am by Jason Byrnes | 1818 views | 5 replies |

ccooper309155

Multiple Update of SOME records

Hi

Update Multiple Records behavoir.

I'm trying to create a page that will update SOME (but not all) of the records for products listed as part of an order in the OrderDetails table.

I've already created a page that will "multiple update" ALL of the products in a given order and it works well.

(Each product has its own status: Allotted, Backorder, Shipped, etc.)

So if, for instance, I have an order with 5 products with two having Allotted status and three having Backorder status, I might want to "Multiple Update" the two Allotted status products to Shipped status and leave the Backorder status products unchanged.

The trouble is, I've created a page with a recordset and repeating region that lists only the two Allotted status items but when I run the Multiple Update, it updates the status of all five records to Shipped status, including the three Backorder products not shown on the page.

Any idea what I am doing wrong or what I need to do?

Using ASP VB and the latest Data Assist.

Sign in to reply to this post

Jason ByrnesWebAssist

Send a copy of the page so I can examine the code.

Sign in to reply to this post

ccooper309155

The Code

Here is the code from the Insert Multiple Records behavior.

Let me know if you need the whole page as I'll need to remove some sensitve info from it first.

Thanks

Craig

<%
' WA DataAssist Multiple Updates
if (cStr(Request.Form("btnUpdate")) <> "") then
WA_loopedIDField = Array("WADA_RepeatID_DetailOrderID")
WA_connection = MM_conn_dmw_orders_STRING
WA_table = "OrderDetails"
WA_redirectURL = "babyback2.asp"
WA_keepQueryString = false
WA_indexField = "DetailOrderID"
WA_fieldNamesStr = "DetailStatus"
WA_columnTypesStr = "',none,''"
WA_fieldNames = Split(WA_fieldNamesStr,"|")
WA_columns = Split(WA_columnTypesStr,"|")
WA_multipleUpdateCounter = 0
while (WA_AB_checkLoopedFieldsNotBlank(WA_loopedIDField, WA_multipleUpdateCounter))
WA_fieldValuesStr = "" & cStr( Request.Form("SomeStatusNeue") ) & ""
WA_fieldValues = Split(WA_fieldValuesStr,"|")
WA_where_fieldValuesStr = WA_AB_getLoopedFieldValue(cStr(WA_loopedIDField(0)), WA_multipleUpdateCounter)
WA_where_columnTypesStr = "none,none,NULL"
WA_where_comparisonStr = "="
WA_where_fieldNames = Split(WA_indexField,"|")
WA_where_fieldValues = Split(WA_where_fieldValuesStr,"|")
WA_where_columns = Split(WA_where_columnTypesStr,"|")
WA_where_comparisions = Split(WA_where_comparisonStr, "|")
updateParamsObj = WA_AB_generateInsertParams(WA_fieldNames, WA_columns, WA_fieldValues, -1)
WhereObj = WA_AB_generateWhereClause(WA_where_fieldNames, WA_where_columns, WA_where_fieldValues, WA_where_comparisions)
set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = WA_connection
MM_editCmd.CommandText = "UPDATE " & WA_table & " SET " & updateParamsObj(3) & " WHERE " & WhereObj & ""
MM_editCmd.Execute()
MM_editCmd.ActiveConnection.Close()
WA_multipleUpdateCounter = WA_multipleUpdateCounter + 1
wend
if (WA_redirectURL <> "") then
if (WA_keepQueryString AND Request.QueryString <> "" AND Request.QueryString.Count > 0) then
if (inStr(WA_redirectURL,"?") > 0) then
WA_redirectURL = WA_redirectURL & "&"
else
WA_redirectURL = WA_redirectURL & "?"
end if
WA_redirectURL = WA_redirectURL & Request.QueryString
end if
Response.Redirect(WA_redirectURL)
end if
end if
%>

Sign in to reply to this post

Jason ByrnesWebAssist

the records to be updated will be taken from the WADA_RepeatID_DetailOrderID hidden form element

You will need to edit the ID column in the multiple Update server behavior to use the status column, Then edit the WADA_RepeatID_DetailOrderID hidden form elements value to the status you wish to update.

Sign in to reply to this post

ccooper309155

Originally Said By: Jason Byrnes
  the records to be updated will be taken from the WADA_RepeatID_DetailOrderID hidden form element

You will need to edit the ID column in the multiple Update server behavior to use the status column, Then edit the WADA_RepeatID_DetailOrderID hidden form elements value to the status you wish to update.  




But won't changing the value of WADA_RepeatID_DetailOrderID to the value of the status I wish to update change EVERY record in the status column with that particular status?

It seems that if the records to be updated will be taken from the WADA_RepeatID_DetailOrderID hidden form element, then it really is an all or nothing thing; that one can only update ALL of the records with the same DetailOrderID and just SOME of the records with the same DetailOrderID.

Sign in to reply to this post

Jason ByrnesWebAssist

Yes, that is one issue with multiple updates, you need a way to uniquely identify the records you want to update.

with a multiple update procedure, that can become difficult if you use a unique identifier that is also included in records you dont wish to update.

the multiplle update procedure uses the WADA_RepeatID_DetailOrderID hidden form element and the ID column you specify to create the WHERE clause of the update statement to determine which records to update.

You could set the WADA_RepeatID_DetailOrderID hidden form element to Use the DetailID column from the recordset as the value and set the ID column in the multiple update procedure to use the DetailID column as the ID column.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...