|
Update multiple records AND post to 2 tables Posted: 03 Mar 2008 05:52 AM |
Hi Julian,
I'm a big fan of your site and have been for a couple of years. I have the following code which is working very well:
<%
if request("selected") <> "" Then
st.MoveFirst
while not st.eof
ID_Unique=st("ID_Unique")
st("Colour1")=Request("Colour1" & ID_Unique)
st("Stock")=Request("Stock" & ID_Unique)
st.update
st.Movenext
wend
response.redirect "Admin.asp"
end if
%>
However, I would also like to write the same recordset to another table. I tried the following code but it's not working:
<%
if request("selected") <> "" Then
st.MoveFirst
while not st.eof
ID_Unique=st("ID_Unique")
st("Colour1")=Request("Colour1" & ID_Unique)
st("Stock")=Request("Stock" & ID_Unique)
st.update
st.Movenext
wend
keeptrack.AddNew
keeptrack("Amend_Date")=Request("DateofAmend")
keeptrack("ID_Short")=Request(st.Fields.Item("ID_Short").Value)
keeptrack.Update
response.redirect "Admin.asp"
end if
%>
Can you tell me where I'm going wrong?
With thanks,
Pat from UK
|
|
|
 |
|
|
Re: Update multiple records AND post to 2 tables Posted: 04 Mar 2008 05:58 AM |
UPDATE:
I have this code now working - but it is only writing one record at a time to the table via the "enter" recordset (even though I am doing batch update).
How to write ALL batch updates to a second table? Pulling out my hair on this one.
<%
if request("selected") <> "" Then
st.MoveFirst
while not st.eof
ID_Unique=st("ID_Unique")
st("Colour1")=Request("Colour1" & ID_Unique)
st("Stock")=Request("Stock" & ID_Unique)
st.update
st.Movenext
wend
end if
%>
<%
if Request("selected") <> "" Then
enter.AddNew
enter("Amend_Date")=Request("Amend_Date")
enter("Colour1")=Request("Colour1" & ID_Unique)
enter("Stock")=Request("Stock" & ID_Unique)
enter.Update
Response.Redirect("Admin.asp")
end if
%> |
|
|
 |
|
|
Re: Update multiple records AND post to 2 tables Posted: 09 Mar 2008 05:01 PM |
You'd need to combine the snippets. ie
<%
if request("selected") <> "" Then
st.MoveFirst
while not st.eof
ID_Unique=st("ID_Unique")
st("Colour1")=Request("Colour1" & ID_Unique)
st("Stock")=Request("Stock" & ID_Unique)
st.update
enter.AddNew
enter("Amend_Date")=Request("Amend_Date")
enter("Colour1")=Request("Colour1" & ID_Unique)
enter("Stock")=Request("Stock" & ID_Unique)
enter.Update
st.Movenext
wend
end if
%>
<%
if Request("selected") <> "" Then
Response.Redirect("Admin.asp")
end if
%> |
Julian Roberts
Site Administrator |
|
 |
|