System.NullReferenceException: Object reference
Posted by: William Reed
Date: March 01, 2007 07:30AM

I get the following error below when I do the following code with the newest dot net connector, this error is sporatic and I dont know why it happens. Basically I connect from my development machine and the page starts working, then I put it on production and its fine. After a while this error crops up on this code....Anyone have any idea why that code below shows up, this sub routine is the first sub called that connects to mysql.

Sub GetLatestWeek()
Dim MyConn As MySqlConnection
MyConn = New MySqlConnection(ConfigurationManager.ConnectionStrings("strConn").ConnectionString)

Dim strSQL As String = "SELECT MAX(week) FROM power_rankings"

Dim myCommand As New MySqlCommand(strSQL, MyConn)

Try
MyConn.Open()

Dim objReader As MySqlDataReader
objReader = myCommand.ExecuteReader()

While objReader.Read()
intLatestIssue = objReader.GetValue(0)
End While

Catch myException As Exception
lblStatus.Text = myException.ToString
Finally
MyConn.Close()
End Try
End Sub

System.NullReferenceException: Object reference not set to an instance of an object. at MySql.Data.MySqlClient.NativeDriver.Configure(MySqlConnection connection) at MySql.Data.MySqlClient.MySqlConnection.Open() at _Default.LoadDL()

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.