Hi guys can you help me out.
i want to display the item in my textbox but how can i do that
i tried to search tru web but nothings working for me.

it is something like this

"SELECT Department FROM Table1 WHERE Department = " & .Textbox1.Text & ""
textbox2.text = rs.fields(1)
textbox3.text = rs.fields(2)

it will display the data it find to my textbox

Recommended Answers

All 4 Replies

Can you provide a little more code? Are you using SqlClient, OleDb, ADO, etc? Does the sample code here help?

why are you selecting Department when you already know what it is... I think you mean something like
SELECT * FROM Table1 WHERE Department = "'" + Textbox1.Text + "'". You should replace the * with the columns you want returned.

I liked to use Oledb and i want to put the data it find in a textbox

con.open
SELECT * FROM Table1 WHERE Department = "'"
'and if the search is true it will place the data in textbox
textbox1.text = rs!fields(1)
textbox2.text = rs!fields(2)
textbox3.text = rs!fields(3)

something like that..

Try

Dim cmd As New OleDbCommand("", con)

cmd.CommandText = "SELECT * FROM Table1 WHERE Department = ?"
cmd.Parameters.AddWithValue("@dept", txtDept.Text)

con.Open()
Dim rdr As OleDbDataReader = cmd.ExecuteReader()

If rdr.Read Then
    TextBox1.Text = rdr.GetString(0)
    TextBox1.Text = rdr.GetString(1)
    TextBox1.Text = rdr.GetString(2)
End If

rdr.Close()
con.Close()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.