Question Search Button Help

Mich Austria

Member
Joined
Feb 13, 2012
Messages
14
Location
Batangas City, Philippines
Programming Experience
Beginner
search.png

What do i need to put in the search button so the words that i will put in the textboxes on the rightside will show the results on the left?

thanks for the reply. i need some codes for pattern.. :fat:

the table name is Customers..

all i found in google is searching in a datagridview. i dont know how to put them in textboxes..
 
Are you using a TableAdapter to retrieve the data?

i dunno.. these are my codes in the search button..

Dim id As String
Dim title As String
Dim country As String
Dim city As String
Dim name As String
Dim cmd As New OleDb.OleDbCommand
id = txtsID.Text
title = txtsTitle.Text
country = txtsCountry.Text
city = txtsCity.Text
name = txtsName.Text


If Not con.State = ConnectionState.Open Then
con.Open()
End If


cmd.Connection = con
txtcID.Text = cmd.CommandText = "Select * FROM Customers WHERE (Customer ID LIKE '%" & id & "%')"
txtCity.Text = cmd.CommandText = "Select * FROM Customers WHERE (City LIKE '%" & city & "%')"
txtCountry.Text = cmd.CommandText = "Select * FROM Customers WHERE (Country LIKE '%" & country & "%')"
txtContact.Text = cmd.CommandText = "Select * FROM Customers WHERE (Contact Name LIKE '%" & name & "%')"
txtcTitle.Text = cmd.CommandText = "Select * FROM Customers WHERE (Contact Title LIKE '%" & title & "%')"
 
Are you using a TableAdapter to retrieve the data?

THESE ARE IN THE FORM LOAD

con = New OleDb.OleDbConnection
con.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source =" & Application.StartupPath & "\DatabaseChallenge.mdb"
con.Open()
sql = "SELECT * from Customers"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "Customers")
con.Close()
MaxRows = ds.Tables("Customers").Rows.Count
inc = -1

it looks like a mess.. but still.. i tried my best.. :crying:
 
you would likely have to try something similar to below. This is searching a dataset for the correct row of data. Once found you can fill all the other fields using the number (82 in the example below) that represents that data in your original query. So in my query that fills that dataset (Call Log) the customers name is the 82nd item in the query.

VB.NET:
Dim answer as string = searchbox.text
Dim foundRowsCL() As Data.DataRow

        Try
            foundRowsCL = dsCallLog.Tables("Call Log").Select("SerialNO = " & answer)
Catch ex As Exception
            MsgBox("Serial number not found, did you include the leading 0 ?" & ex.ToString, MsgBoxStyle.Question, "Serial search error")
            Exit Sub
        End Try

'Now fill the rest of the boxes after finding the data searched
 CustomerTB.Text = (foundRowsCL(0).Item(82)).ToString
 
Back
Top