Click here to Skip to main content
11,411,494 members (66,939 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: SQL ADO.NET Access VB.NET
I'm trying to get a record by using the Id from the client but it keeps telling me no record found

here is the code:

 Private Sub btnBuscar_Click(sender As Object, e As EventArgs) Handles btnBuscar.Click
            Dim str As String ' str = string "string"
            str = "SELECT * FROM tblClientes WHERE (NumId = " & txtNumID.Text & ")"
            'Instruccion de SQL
            Dim comando As OleDbCommand = New OleDbCommand(str, miConeccion)
            dataReader = comando.ExecuteReader
            While dataReader.Read()
                txtNombre.Text = dataReader("Nombre").ToString
                txtApe.Text = dataReader("Apellido").ToString
                txtCiudad.Text = dataReader("Ciudad").ToString
                txtNumT.Text = dataReader("Telefono").ToString
                txtSS.Text = dataReader("Seguro Social").ToString
                txtZipCode.Text = dataReader("ZipCode").ToString
            End While
        Catch ex As Exception
            'mensaje en caso de error;
            MsgBox("No se encontro la informacion")
        End Try
    End Sub
I'm not used to VB most of the time I use C# and I do not know if it's a bracket thing or something else, Thank You
Posted 23-Feb-13 22:54pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If it is saying that no records are found, it is because there are no records where the NumId batch the text you typed in the text box. Check your data - both the text box content and the database.

And don't do it like that!
Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.

If what you mean is that you get the message box saying "No se encontro la informacion", then you need to look at the exception detail, either by adding it to the message box text, or by looking with the debugger - we can't give accurate advice if we don't know what it is complaining about!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 223
1 Sascha Lefévre 155
2 Sergey Alexandrovich Kryukov 149
3 ProgramFOX 90
4 Dave Kreskowiak 90
0 Sergey Alexandrovich Kryukov 8,920
1 OriginalGriff 7,128
2 Maciej Los 3,440
3 Abhinav S 3,248
4 Peter Leow 3,059

Advertise | Privacy | Mobile
Web04 | 2.8.150414.5 | Last Updated 24 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100