E
Etayki
Hi!
I am trying to read and update my database at the same time, but it
doesn't seem to be working:
Dim myCommand As New System.Data.SqlClient.SqlCommand("SELECT
* FROM Keyword", conn)
Dim myReader As System.Data.SqlClient.SqlDataReader =
myCommand.ExecuteReader(CommandBehavior.CloseConnection)
While myReader.Read()
'Console.WriteLine(myReader("coil_search"))
If Not myReader("coil_search") Then
keyword = myReader("keyword")
Dim cmd3 As New
System.Data.SqlClient.SqlCommand("UPDATE Keyword SET coil_search =
'True' WHERE keyword =" + keyword, conn)
cmd3.ExecuteNonQuery()
End If
End While
myReader.Close()
During runtime I get this error in association with
"cmd3.ExecuteNonQuery()":
"There is already an open DataReader associated with this Command
which must be closed first."
Is there a way that I can update the database while the DataReader is
still open? It is inefficient to have to close it and open it each
time I need to update the table.
Thanks,
Etay
I am trying to read and update my database at the same time, but it
doesn't seem to be working:
Dim myCommand As New System.Data.SqlClient.SqlCommand("SELECT
* FROM Keyword", conn)
Dim myReader As System.Data.SqlClient.SqlDataReader =
myCommand.ExecuteReader(CommandBehavior.CloseConnection)
While myReader.Read()
'Console.WriteLine(myReader("coil_search"))
If Not myReader("coil_search") Then
keyword = myReader("keyword")
Dim cmd3 As New
System.Data.SqlClient.SqlCommand("UPDATE Keyword SET coil_search =
'True' WHERE keyword =" + keyword, conn)
cmd3.ExecuteNonQuery()
End If
End While
myReader.Close()
During runtime I get this error in association with
"cmd3.ExecuteNonQuery()":
"There is already an open DataReader associated with this Command
which must be closed first."
Is there a way that I can update the database while the DataReader is
still open? It is inefficient to have to close it and open it each
time I need to update the table.
Thanks,
Etay