Click here to Skip to main content
12,244,489 members (40,824 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 24 Feb 2013
Copyright © CodeProject, 1999-2016
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