Hai,

I am Getting some query Result in a OLEDBDataReader. In one case I am using .read method, and in another case I am using that Reader as DataSource of a DataGrid,and do DataBind.
It giving expected result some time,and some other times,it is showing Error,Null Refernce,Object Reference not set to instance of a object.If refreshed again and again, It is showing the result.
What is the problem,How to overcome this?

Here is the code that populates the objDataReder.

Public Shared Function ShowResult(ByVal Qry As String) As Object
Try
If Not (objDataReader Is Nothing) Then
objDataReader.Close()
End If
selectCmd = New OleDbCommand(Qry, objCon)
'objCon is the connection object that is opened in session_OnStart.

objDataReader = selectCmd.ExecuteReader()
Return objDataReader
Catch
errorTracer()
End Try
End Function

Help in time will be grateful.

Regards
sindhuja