DEALING WITH NULL QUERY RESULTS

  • Thread starter Thread starter Savas Ates
  • Start date Start date
S

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..
 
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
 
Back
Top