This is my first question in stackoverflow and I'm a novice in .NET, so forgive me for the stupid question if it is so! When I test it in local no problem. On the server, it starts working good but after some time (more probably after some visitors visit the site) it stops working with this error and about 30mins later it starts working back. Here is my code: code behind:
Dim baglanti As String = "Data Source=xxx.xxx.xxx;Initial Catalog=xxVT;Persist Security Info=True;User ID=xxx;Password=xxx"
Public mRs As SqlDataReader
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Conn As SqlConnection
Conn = New SqlConnection(baglanti)
Conn.Open()
Dim lcSQLCommand1 As New SqlCommand("Select * from Fiyatlar", Conn)
mRs = lcSQLCommand1.ExecuteReader()
End Sub
aspx page:
<% If Not IsNothing(mRs) Then 'I also tried with IsDBNull here, but same result.
Do While mRs.Read %>
<!--do some job with mRs-->
<%Loop
mRs.close()
end if %>
and this is the error message: Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 22: Line 23: <% If Not IsDBNull(mRs) Then
Line 24: Do While mRs.Read%>
Line 25:
Line 26: