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 = "SELECT * FROM tblClientes WHERE (NumId = " & txtNumID.Text & ")"
Dim comando As OleDbCommand = New OleDbCommand(str, miConeccion)
dataReader = comando.ExecuteReader
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
Catch ex As Exception
MsgBox("No se encontro la informacion")
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
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!
Edited 23-Feb-13 22:09pm
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)