DataReader Vacio

02/08/2004 - 23:59 por HH | Informe spam
Hola a todos.
Como hago para saber cuando un DataReader no tiene
registros ?

Preguntas similare

Leer las respuestas

#1 Angel. E. Ruiz. Pastor
03/08/2004 - 02:54 | Informe spam
Dim connString As String = "Data Source=myserver; Initial Catalog=tots; User
ID=sa; Password="
Dim i As Int32
Dim conn As New System.Data.SqlClient.SqlConnection(connString)
conn.Open()
Dim cmd As New System.Data.SqlClient.SqlCommand("select * from tblLeads",
conn)
Dim reader As SqlDataReader
Try
reader = cmd.ExecuteReader()
Catch e As Exception
Debug.WriteLine(e)
Debug.WriteLine(sql)
Return New System.Collections.ArrayList
End Try
Do While reader.Read()
' tiene registros
Loop
conn.Close()


Saludos cordiales,
Ángel Ruiz
[MS Visual Basic Developer MVP]
Caracas - Venezuela

"El conocimiento es un bien, que crece a medida que se comparte"

"HH" wrote in message
news:9b6a01c478db$f800a7e0$
Hola a todos.
Como hago para saber cuando un DataReader no tiene
registros ?

Respuesta Responder a este mensaje
#2 fernando
03/08/2004 - 08:52 | Informe spam
hola tambien puedes preguntar:
if reader.HasRows then ' aca le estas preguntando si tiene algo , si
es TRUE es porque tiene, de lo contrario no tiene
'aca adentro el codigo
endif
espero te sirva.

fernando
"HH" escribió en el mensaje
news:9b6a01c478db$f800a7e0$
Hola a todos.
Como hago para saber cuando un DataReader no tiene
registros ?

Respuesta Responder a este mensaje
#3 HH
03/08/2004 - 17:11 | Informe spam
Funciono de maravilla.

Gracias !!!



Dim connString As String = "Data Source=myserver; Initial


Catalog=tots; User
ID=sa; Password="
Dim i As Int32
Dim conn As New System.Data.SqlClient.SqlConnection


(connString)
conn.Open()
Dim cmd As New System.Data.SqlClient.SqlCommand("select *


from tblLeads",
conn)
Dim reader As SqlDataReader
Try
reader = cmd.ExecuteReader()
Catch e As Exception
Debug.WriteLine(e)
Debug.WriteLine(sql)
Return New System.Collections.ArrayList
End Try
Do While reader.Read()
' tiene registros
Loop
conn.Close()


Saludos cordiales,
Ángel Ruiz
[MS Visual Basic Developer MVP]
Caracas - Venezuela

"El conocimiento es un bien, que crece a medida que se


comparte"

"HH" wrote in


message
news:9b6a01c478db$f800a7e0$
Hola a todos.
Como hago para saber cuando un DataReader no tiene
registros ?





.

email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida