DEALING WITH NULL QUERY RESULTS

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..
 
C

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top