Note that there are some explanatory texts on larger screens.

plurals
  1. POdata reader assosiated with connection which must be closed mistake
    text
    copied!<p>I have this bizarre mistake which I can't find a solution yet. I have a function which I envoke every time when I have to insert data in database. And its actually working because when i check the database entries they are actually there. </p> <p>However I have this annoying mistake "There is already an open data reader assosiated with connection which must be closed". and I can't find a way to get read of it. </p> <p>This is the function:</p> <pre><code>Sub InputDataValues(ByVal StrQwery As String) Try myconn.Open() Dim stquery As String = StrQwery Dim smd As MySqlCommand smd = New MySqlCommand(stquery, myconn) smd.ExecuteReader() smd.ExecuteReader().Close()//I added this when I wanted to get rid if the mistake myconn.Close() Catch ex As Exception Dim ErrorMessage As String = "alert('" &amp; ex.Message.ToString() &amp; "');" Page.ClientScript.RegisterStartupScript(Me.GetType(), "ErrorAlert", ErrorMessage, True) myconn.Close() End Try myconn.Close() End Sub </code></pre> <p>And this is how I call it several times down in the code:</p> <pre><code>InputDataValues(StrQwery) </code></pre> <p>If anyone cam give me a hint I will be most grateful.</p> <p>This is how it look when i changed it to ExecuteNonQuery</p> <pre><code>Sub InputDataValues(ByVal StrQwery As String) Try myconn.Open() Dim stquery As String = StrQwery Dim retValue As Integer Dim smd As MySqlCommand smd = New MySqlCommand(stquery, myconn) retValue = smd.EndExecuteNonQuery() myconn.Close() Catch ex As Exception Dim ErrorMessage As String = "alert('" &amp; ex.Message.ToString() &amp; "');" Page.ClientScript.RegisterStartupScript(Me.GetType(), "ErrorAlert", ErrorMessage, True) myconn.Close() End Try myconn.Close() End Sub </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload