Home All Groups Group Topic Archive Search About

DEALING WITH NULL QUERY RESULTS

Author
24 Apr 2006 10:15 AM
Savas Ates
The error
Invalid attempt to read when no data is present.


email = Request.Form.Item("demail")

sifre = Request.Form.Item("dsifre")








Dim durum As Object

rs = New SqlClient.SqlCommand("ST_CHECKUSER @email='" & email & "' ,
@sifre='" & sifre & "'", baglantim)

xx = rs.ExecuteReader

durum = xx(0)

If IsDBNull(durum) Then

Label1.Text = "YOK"

Else

Label1.Text = "VAR"

End If



How to handle NULL query resultset in my codebehind after executing my SP
which can return null resultset..

Author
24 Apr 2006 1:15 PM
Chris Dunaway
Your error is caused by not calling the Read method of the DataReader.


xx = rs.ExecuteReader

If xx.HasRows Then
    xx.Read

    diri, = xx(0)

....

End If