Monday, March 26, 2012

The connections current state is Connecting.

Only on one page that I got in my project do I get this error:

ExecuteReader requires an open and available Connection. The connection's current state is Connecting.

Shouldn't the connection object automatically wait until it's open and then move on ?

The code:


Dim SQL As String, MyRead As OleDb.OleDbDataReader

Try
MyConn = New OleDb.OleDbConnection(ConfigurationSettings.AppSettings("ConnectionString"))
If MyConn.State <> ConnectionState.Open Then
MyConn.Open()
End If
Try
SQL = "SELECT * FROM tbl_table"
Dim MyCMD As New OleDb.OleDbCommand(SQL, MyConn)
MyRead = MyCMD.ExecuteReader
MyCMD.Dispose()
If Not MyRead.Read = False Then
LN = MyRead.GetString(0)
FN = MyRead.GetString(1)
EML = MyRead.GetString(2)
PHN = MyRead.GetString(3)
ADD = MyRead.GetString(4)
CITY = MyRead.GetString(5)
STATE = MyRead.GetString(6)
ZIP = MyRead.GetString(7)
COUNTRY = MyRead.GetString(8)
FAX = MyRead.GetString(9)
CELL = MyRead.GetString(10)
URL = MyRead.GetString(11)
COMPANY = MyRead.GetString(12)
End If
Catch ex As Exception
Call READ_EXCEPTION(ex)
Finally
MyRead.Close()
End Try
Catch ex As Exception
Call READ_EXCEPTION(ex)
Finally
MyConn.Dispose()
End Try

Have you stepped through the code to find out if it's executing the myConn.Open method?
Not yet, the thing is that I can just refresh the page and it will start loading normally, it will do this completely at random.

0 comments:

Post a Comment