Foros del Web » Programación para mayores de 30 ;) » .NET »

validar myReader.read()

Estas en el tema de validar myReader.read() en el foro de .NET en Foros del Web. hola tengo la siguiente consulta.. Dim myConnection As New OleDb.OleDbConnection("Provider=SQLOLEDB;......... ) Dim mySelectQuery As String = "select MAX(clave) from clave " Dim myCommand As New ...
  #1 (permalink)  
Antiguo 02/07/2010, 00:03
 
Fecha de Ingreso: junio-2010
Mensajes: 9
Antigüedad: 13 años, 10 meses
Puntos: 0
validar myReader.read()

hola tengo la siguiente consulta..
Dim myConnection As New OleDb.OleDbConnection("Provider=SQLOLEDB;......... )
Dim mySelectQuery As String = "select MAX(clave) from clave "

Dim myCommand As New OleDb.OleDbCommand(mySelectQuery, myConnection)
myConnection.Open()
Dim myReader As OleDb.OleDbDataReader = myCommand.ExecuteReader()
Try

While myReader.Read()


tc.Text = myReader.GetValue(0) + 1


End While

Finally
myReader.Close()
myConnection.Close()
End Try
me podrian ayudar en como valido el myReader.read() si es la primera consulta y la columna clave no tiene ningun registro y que me agrege a tc.text 1 que es el 1r valor

se los agradecería mucho Gracias
  #2 (permalink)  
Antiguo 02/07/2010, 05:57
Avatar de gedarufi  
Fecha de Ingreso: diciembre-2008
Ubicación: Colombia
Mensajes: 540
Antigüedad: 15 años, 4 meses
Puntos: 22
Respuesta: validar myReader.read()

Puedes utilizar myReader.HasRows con eso sabrás si tu consulta te retorno algún valor o no.

Saludos
  #3 (permalink)  
Antiguo 03/07/2010, 12:38
 
Fecha de Ingreso: junio-2010
Mensajes: 6
Antigüedad: 13 años, 9 meses
Puntos: 0
Respuesta: validar myReader.read()

hola alebam esto te puede ayudar mucho lo utilizo para crear nuevos codigos

Dim CN As New SqlConnection("DATA SOURCE=PIER\SQLSERVER2005;USER ID=SA;PWD=;DATABASE=base")
Dim SQL As String
SQL = "SELECT MAX(COD_CLIENTE)FROM CLIENTE"
Dim CMD As New SqlCommand
Dim DR As SqlDataReader
CMD.CommandType = CommandType.Text
CMD.Connection = CN
CMD.CommandText = SQL
CN.Open()
DR = CMD.ExecuteReader
DR.Read()
If IsDBNull(DR.Item(0)) Then
TextBox1.Text = Format(1, "00000")
Else
TextBox1.Text = Format(CType(DR.Item(0), Integer) + 1, "00000")
End If
CN.Close()

espero te sirva de ayuda
  #4 (permalink)  
Antiguo 04/07/2010, 21:14
 
Fecha de Ingreso: junio-2010
Mensajes: 9
Antigüedad: 13 años, 10 meses
Puntos: 0
Respuesta: validar myReader.read()

muchas gracias pier_cajo es lo que necesitaba gracias

Etiquetas: sql, sqlserver2005
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:43.