Vhat does this exception mean?!
A few times, our website has gone down throwing the following exception:
System.InvalidOperationException: ExecuteReader: Connection property has not been initialized. at System.Data.SqlClient.SqlCommand.ValidateCommand(S tring method, Boolean executing) at System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior behavior) at subibl.DBUtil.ExecuteSP(Object[,] arr, String spName, SqlConnection cn)
where the ExecuteSP function looks like this:
Public Shared Function ExecuteSP(ByVal arr(,) As Object, ByVal spName As String, ByVal cn As SqlConnection)
Dim cmd As New SqlCommand(spName, cn)
Dim reader As SqlDataReader
Dim i, j As Integer
Try
cmd.CommandType = CommandType.StoredProcedure
For i = 0 To arr.GetUpperBound(0)
cmd.Parameters.Add(arr(i, 0), arr(i, 1))
Next
reader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Return reader
cmd = Nothing
reader = Nothing
Catch ex As Exception
System.Web.HttpContext.Current.Response.Write(ex.T oString)
System.Web.HttpContext.Current.Response.End()
End Try
End Function
Obviously, there is some kind of connection problem to the SQL server. The strange thing is that it occurs without us having done anything, and a few minutes later, perhaps 5-10 minutes, it's up and running again, all by itself. We have checked the event viewer and error logs for clues but nothing.
Any suggestions what can be causing this problem?
|