Buscar dentro de una base de datos

(1/4) > >>

andaluz:
hola tengo un pequeño problemilla el cual al recorren una base de datos que ya tengo creada solo me accede al primer registro.

les pongo el codigo haber si encuentran algo mal y me pueden ayudar.

Código
Private Sub btn_Buscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Buscar.Click
       Dim nombre, dni As String
       Dim edad As Integer
 
       For i = 0 To UsuTableAdapter.GetData.Rows.Count - 1
           nombre = UsuTableAdapter.GetData.Rows(i).Item(0)
           dni = UsuTableAdapter.GetData.Rows(i).Item(1)
           edad = UsuTableAdapter.GetData.Rows(i).Item(2)
           If dni <> txt_DNI_Buscar.Text Then
               fila = i
               MessageBox.Show("DNI encontrado: " & UsuTableAdapter.GetData.Rows(i).Item(1), "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information)
               lbl_DNI_Encontrado.ForeColor = Color.Green
 
               lbl_Nombre.Text = nombre
               lbl_DNI.Text = dni
               lbl_Nombre.Text = edad
               Exit Sub
           Else
               fila = i
               MessageBox.Show("ERROR")
               'Exit Sub
           End If
       Next
   End Sub
 

saludos

andaluz:
tiene algun fallo el código???

andaluz:
me gustaria saber porque si le introduzco un dni correcto me devuelve la misma información que si le introduzco un dni incorrecto???

espero que me puedan ayudar!!!!

saludos

Novlucker:
Cita de: andaluz en 24 Febrero 2012, 18:09 pm

Código
Private Sub btn_Buscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Buscar.Click
       Dim nombre, dni As String
       Dim edad As Integer
 
       For i = 0 To UsuTableAdapter.GetData.Rows.Count - 1
           nombre = UsuTableAdapter.GetData.Rows(i).Item(0)
           dni = UsuTableAdapter.GetData.Rows(i).Item(1)
           edad = UsuTableAdapter.GetData.Rows(i).Item(2)
           If dni <> txt_DNI_Buscar.Text Then
               fila = i
               MessageBox.Show("DNI encontrado: " & UsuTableAdapter.GetData.Rows(i).Item(1), "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information)
               lbl_DNI_Encontrado.ForeColor = Color.Green
 
               lbl_Nombre.Text = nombre
               lbl_DNI.Text = dni
               lbl_Nombre.Text = edad
               Exit Sub
           Else
               fila = i
               MessageBox.Show("ERROR")
               'Exit Sub
           End If
       Next
   End Sub


Saludos

andaluz:
este codigo es el mismo que he publicado yo en primer lugar o tiene algun cambio??

Navegación

[0] Índice de Mensajes

[#] Página Siguiente