mcavanilla
Member
- Joined
- Apr 2, 2013
- Messages
- 5
- Programming Experience
- Beginner
Hello,
Could someone help me to display the result of a search in textbox?
I have a table ("TBClient"), with two columns "Company" and "Name". My form has a combox to select the name of a column, and a textbox to write what i'm looking for. Below this, i have a textbox to display the result.
How can I search for a company and display the result (the name of the company), into this texbox.
I'm using VS2010, SQL server 2008 and DataSet
My code:
Private Sub btnPesquisa1_Click(sender As Object, e As System.EventArgs) Handles btnPesquisa1.Click
Dim data As SqlDataAdapter
Dim sql As String
Dim dt As New DataSet
If cmbNames.SelectedIndex = "0" Then
sql = "Select * from TBClient where Company='" & txtpesquisa1.Text & "'"
End If
data = New SqlDataAdapter(sql, cn)
data.Fill(dt, "TBCliente")
Dim dr As DataRow = dt.Tables(0).Rows(0)
DataGrid2.DataSource = dt.Tables(0)
TextBox1.Text = dr("Company").ToString
Thanks for help
Marco
Could someone help me to display the result of a search in textbox?
I have a table ("TBClient"), with two columns "Company" and "Name". My form has a combox to select the name of a column, and a textbox to write what i'm looking for. Below this, i have a textbox to display the result.
How can I search for a company and display the result (the name of the company), into this texbox.
I'm using VS2010, SQL server 2008 and DataSet
My code:
Private Sub btnPesquisa1_Click(sender As Object, e As System.EventArgs) Handles btnPesquisa1.Click
Dim data As SqlDataAdapter
Dim sql As String
Dim dt As New DataSet
If cmbNames.SelectedIndex = "0" Then
sql = "Select * from TBClient where Company='" & txtpesquisa1.Text & "'"
End If
data = New SqlDataAdapter(sql, cn)
data.Fill(dt, "TBCliente")
Dim dr As DataRow = dt.Tables(0).Rows(0)
DataGrid2.DataSource = dt.Tables(0)
TextBox1.Text = dr("Company").ToString
Thanks for help
Marco