B
Brett
I execute an SQL stored procedure that returns 5 records
("SqlCmd_SpamUpdate_spfBlackUnprocessed"). I then open a data reader, loop
through those five records while calling stored procedures that does
updates. The second SP needs information from the 5 records being returned.
The problem is that when I try to execute the stored procedure inside of the
data reader loop, I get an error that a data reader is already open and
should be closed before executing the stored procedure. Any ideas how I can
fix this? Thanks, Brett.
cn_mydatabase.Open()
Dim drspfblacklist As SqlDataReader
drspfblacklist =
SqlCmd_SpamUpdate_spfBlackUnprocessed.ExecuteReader()
While drspfblacklist.Read
-- do something ---
With SqlCmd_BlacklistUpdateStatus
.CommandType = System.Data.CommandType.StoredProcedure
.Parameters("@messageid").Value =
drspfblacklist.Item("message_id")
.Parameters("@subpart").Value = BlackListStatus
.ExecuteNonQuery()
End With
End While
drspfblacklist.Close()
SqlCmd_SpamUpdate_spfBlackUnprocessed.Dispose()
cn_mydatabase.Close()
("SqlCmd_SpamUpdate_spfBlackUnprocessed"). I then open a data reader, loop
through those five records while calling stored procedures that does
updates. The second SP needs information from the 5 records being returned.
The problem is that when I try to execute the stored procedure inside of the
data reader loop, I get an error that a data reader is already open and
should be closed before executing the stored procedure. Any ideas how I can
fix this? Thanks, Brett.
cn_mydatabase.Open()
Dim drspfblacklist As SqlDataReader
drspfblacklist =
SqlCmd_SpamUpdate_spfBlackUnprocessed.ExecuteReader()
While drspfblacklist.Read
-- do something ---
With SqlCmd_BlacklistUpdateStatus
.CommandType = System.Data.CommandType.StoredProcedure
.Parameters("@messageid").Value =
drspfblacklist.Item("message_id")
.Parameters("@subpart").Value = BlackListStatus
.ExecuteNonQuery()
End With
End While
drspfblacklist.Close()
SqlCmd_SpamUpdate_spfBlackUnprocessed.Dispose()
cn_mydatabase.Close()