d2fox
09-11-2005, 08:10 AM
I have this code and it only seems to updates the first record (the first time through the FOR loop).
I retrieve a string of CONFIRMED PARTICIPANTS, separated by commas, from my web page. Then I execute the below to update each CONFIRMED PARTICIPANT. If I display the query each time through, they look fine. Is there some constraint where you can only do one update in a connection?
connectstr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("access/mydatabase.mdb") & ";"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Connectstr
Set rsData = Server.CreateObject("ADODB.Recordset")
g_input=split(request("participantselect"),",")
num_inputted=ubound(g_input)
for counter =0 to num_inputted
UserSQL = "Update tblActivities SET confirmed = true where ProgramId = "
UserSQL = UserSQL & "'" & InputProgramID & "'"
UserSQL = UserSQL & " and ParticipantID = "
UserSQL = UserSQL & "'" & g_input(counter) & "'"
Conn.execute UserSQL
next
Conn.Close
End If
ALTERNATIVELY, I've tried:
connectstr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("access/mydb.mdb") & ";"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Connectstr
Set rsData = Server.CreateObject("ADODB.Recordset")
g_input=split(request("participantselect"),",")
num_inputted=ubound(g_input)
UserSQL = "Update tblActivities SET confirmed = True where ProgramId = "
UserSQL = UserSQL & "'" & InputProgramID & "'"
UserSQL = UserSQL & " AND ParticipantID IN ("
For counter = 0 To num_inputted
InClause = InClause & "'" & g_input(counter) & "',"
Next
UserSQL = UserSQL & Left(InClause,Len(InClause)-1) & ")"
rsData.Open UserSQL, Conn, 2, 3
response.write (usersql)
rsData.Close
Conn.Close
End If
The SQL displayed is:
Update tblActivities SET confirmed = True where ProgramId = '21' AND ParticipantID IN ('10',' 14',' 5')
(looks ok to me)
This code again updates only the first participant in the list and then I get an error on the Close, saying that the
"Operation is not allowed when the object is closed. "
Can someone identify what I'm doing wrong?
Thanks!
I retrieve a string of CONFIRMED PARTICIPANTS, separated by commas, from my web page. Then I execute the below to update each CONFIRMED PARTICIPANT. If I display the query each time through, they look fine. Is there some constraint where you can only do one update in a connection?
connectstr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("access/mydatabase.mdb") & ";"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Connectstr
Set rsData = Server.CreateObject("ADODB.Recordset")
g_input=split(request("participantselect"),",")
num_inputted=ubound(g_input)
for counter =0 to num_inputted
UserSQL = "Update tblActivities SET confirmed = true where ProgramId = "
UserSQL = UserSQL & "'" & InputProgramID & "'"
UserSQL = UserSQL & " and ParticipantID = "
UserSQL = UserSQL & "'" & g_input(counter) & "'"
Conn.execute UserSQL
next
Conn.Close
End If
ALTERNATIVELY, I've tried:
connectstr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("access/mydb.mdb") & ";"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Connectstr
Set rsData = Server.CreateObject("ADODB.Recordset")
g_input=split(request("participantselect"),",")
num_inputted=ubound(g_input)
UserSQL = "Update tblActivities SET confirmed = True where ProgramId = "
UserSQL = UserSQL & "'" & InputProgramID & "'"
UserSQL = UserSQL & " AND ParticipantID IN ("
For counter = 0 To num_inputted
InClause = InClause & "'" & g_input(counter) & "',"
Next
UserSQL = UserSQL & Left(InClause,Len(InClause)-1) & ")"
rsData.Open UserSQL, Conn, 2, 3
response.write (usersql)
rsData.Close
Conn.Close
End If
The SQL displayed is:
Update tblActivities SET confirmed = True where ProgramId = '21' AND ParticipantID IN ('10',' 14',' 5')
(looks ok to me)
This code again updates only the first participant in the list and then I get an error on the Close, saying that the
"Operation is not allowed when the object is closed. "
Can someone identify what I'm doing wrong?
Thanks!