0

Hi guys,
basically i have a form with textboxes such as
First name
surname
phone number
in.
and each row has an auto number assigned to it.
that auto number is the customers reference number.
basically i want to be able to enter a reference number into a text box and when a button is clicked i want to extract all the name and phone number from the database and put them into the relevant text boxes.
how would i go about doing this?

this is essentially a search and output problem


Thanks

Ross

3
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by Pgmer
0

Select * from Customer where customerreferene number='Pass the reference number'.
Fill the data set with the records, loop through all the records and assign the values to the respective textboxes.

0

my code at the moment is

Try
            connection.Open()
            cmd = New OleDb.OleDbCommand("SELECT * FROM login where Reference='" & txtReference.Text & "' ", connection)
            datareader = cmd.ExecuteReader()
            If datareader.Read() Then

                txtSurname.Text = datareader("Surname")

            Else
                txtSurname.Text = ""
                MessageBox.Show("No Information  found")
            End If
            connection.Close()
        Catch ex As OleDb.OleDbException
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Oledb Error")
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "General Error")
        End Try

but it says i dont have the right parameters. any ideas? (oledb error)

Edited by rosstafarian: n/a

0

Right guys its all fixed
stupidly tried to read from the wrong table and then the two apostrophes (') in the sql string turned it into a string, which obviously isnt an integer. but all sorted now.

any ideas how i could write a bit of code that over writes a row with updated information?

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.