Hi,
Please help, I'm getting error such as "There is already an open datareader associated with this command which must be closed first..." Below is my code and I am trying to loop through the datareader to match some field, how can I fix this please?
Thank you.
***this is the value of my command text:
Dim strUpdateEditedFlag As String = "UPDATE TEMPDB..SLetterMailMergeVersion " & _
"SET EditedFlag='Y' WHERE StudentID = " & strTmpStudID
Please help, I'm getting error such as "There is already an open datareader associated with this command which must be closed first..." Below is my code and I am trying to loop through the datareader to match some field, how can I fix this please?
Thank you.
VB.NET:
For Each strGetActualFiles As String In strActualFiles
Dim strGetActFilesNoPath As New FileInfo(strGetActualFiles)
Dim strTmpGetActFile As String = strGetActFilesNoPath.Name
Try
My.Computer.FileSystem.CopyFile(strGetActualFiles, filePath & strTmpGetActFile)
Catch cf As Exception
MessageBox.Show(cf.Message & vbCr & errMessage, "Copy File Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End
End Try
Try
dReaderUpdate = cmdReadRecordset.ExecuteReader()
Catch ed As Exception
MessageBox.Show(ed.Message & vbCr & errMessage, "Stored Procedure Call Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
con.Close()
End
End Try
Do While dReaderUpdate.Read
strTmpStudID = dReaderUpdate.GetString(0)
MessageBox.Show(strTmpStudID)
cmdRecordUpdate.CommandText = strUpdateEditedFlag & strTmpStudID
Try
cmdRecordUpdate.ExecuteNonQuery()
MessageBox.Show(strTmpStudID)
dReaderUpdate.Close()
Catch errupd As Exception
MessageBox.Show(errupd.Message & vbCr & errMessage, "Record Update Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
con.Close()
End
End Try
Loop
Next
***this is the value of my command text:
Dim strUpdateEditedFlag As String = "UPDATE TEMPDB..SLetterMailMergeVersion " & _
"SET EditedFlag='Y' WHERE StudentID = " & strTmpStudID
Last edited by a moderator: