Visual Basic 9:
Dim myread As MySqlDataReader
Dim mycomm As MySqlCommand
Dim twConn As New Twitter
Dim strSelectTweet As String
Try
myconn = New MySqlConnection(Me.ConnectionString)
myconn.Open()
strSelectIDs = "SELECT USER_ID,USER_SCREENNAME FROM USERS;"
mycomm = New MySqlCommand
mycomm.Connection = myconn
mycomm.CommandText = strSelectIDs
myread = mycomm.ExecuteReader()
If myread.HasRows() Then
While myread.Read()
ltIDs.Add(myread.GetString("USER_ID"))
End While
End If
myread.Close()
twConn.AuthenticateWith(Me.ConsumerKey, Me.ConsumerKeySecret,
Me.oAuthToken, Me.oAuthTokenSecret)
'MsgBox(twConn.RemainingHits)
For Each strID As String In ltIDs
myread.Close()
If Me.CheckLastDate(strID, myconn) >= 7 Then
Private Function CheckLastDate(ByVal p_strUserID As String, ByRef p_myconn
As MySqlConnection) As Integer
Dim strQueryString As String
Dim mycomm As MySqlCommand
Dim myread As MySqlDataReader
Try
mycomm = New MySqlCommand
mycomm.Connection = p_myconn
strQueryString = "SELECT TWEET_ID,TWEET_CREATEDAT FROM TWEETS
WHERE USER_ID='" & p_strUserID & "' ORDER BY TWEET_CREATEDAT DESC LIMIT
0,1;"
mycomm.CommandText = strQueryString
myread = mycomm.ExecuteReader()
If Not myread.HasRows() Then
Return 0
Else
Dim dtLastTweet As DateTime
myread.Read()
dtLastTweet = myread.GetDateTime("TWEET_CREATEDAT")
myread.Close()
Return DateDiff(DateInterval.Day, dtLastTweet, Now())
End If
Catch ex As MySqlException
Debug.Print(ex.Message)
Return 0
Catch ex As Exception
Debug.Print(ex.Message)
Return 0
End Try
End Function
Problem: This is giving me an Exception. "A first chance exception of type
'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll
There is already an open DataReader associated with this Connection which
must be closed first." Yet I can't figure out where the open dataset is.
| Thread |
|---|
| • Problem with supposedly "open" dataset | John Meyer | 7 Nov 2009 |