Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/06/2011, 19:46
future89
 
Fecha de Ingreso: diciembre-2010
Mensajes: 106
Antigüedad: 13 años, 5 meses
Puntos: 10
Pregunta asignar campo bd a label

Dim leelo As SqlDataReader

myConn = New SqlConnection("Initial Catalog=libroteka;Data Source=localhost;Integrated Security=SSPI;")

myCmd = myConn.CreateCommand
myConn.Open()
' algo mal tiene que estar qui
myCmd.CommandText = "SELECT MAX(cod_boleta) FROM ventas "
leelo = myCmd.ExecuteReader()

While leelo.Read
numeroboleta.Text = leelo.Item("cod_boleta") + 1
' el error me sale aqui
'indexoutofrangeexception cod_boleta
End While

myConn.Close()

----------------------------------------------------------

si lo hago asi me funciona perfecto:


myCmd.CommandText = "SELECT cod_boleta FROM ventas "
leelo = myCmd.ExecuteReader()

While leelo.Read
numeroboleta.Text = leelo.Item("cod_boleta") + 1

End While
leelo.Close()

pero al querer elegir el numero mayor de cod_boleta para sumarle +1 para crear otra boleta no me funciona. :$