I'm using a background worker to do some tasks that involve reading and writing to sql. But the main thread is also continuing to read and write to sql. And I am getting "There is already an open DataReader associated with this Connection which must be closed first." I've seen some talk about MultipleActiveResultSets. But I've also seen caution about them without specifics of what to do or watch for. Would MARS fix my situation?
Here is my current global connection to sql:
When reading from sql I am usually doing something like this. This is where I'm seeing the problem.Code:Public con As SqlConnection ... ConnectionString = "User ID=" & strUser & ";Initial Catalog=" & strDB & ";Data Source=" & strServer & ";Password=" & strPassword & ";" con = New System.Data.SqlClient.SqlConnection(ConnectionString) con.Open()
Using vb.net, vs 2005, sql 2005.Code:Dim comm As New SqlCommand Dim rs As New DataSet comm.Connection = con comm.CommandType = CommandType.StoredProcedure comm.CommandText = "ReadContacts" Dim adapter As New SqlDataAdapter(comm) adapter.Fill(rs, "Contacts")




Reply With Quote