search database?=

KLin816

Member
Joined
Mar 5, 2008
Messages
10
Programming Experience
Beginner
Hi,

i have two database tables from Access, both tables have 20 columns and 40000 records with different data.

i need to create a textbox and a search botton, so when i input a person's name in the textbox i can search both tables' records. if i can find it in the first table then i don't have to search the second table but if i can't find it in the first table then i have to search the second table. when i find a person in the tables, i would like to have that person's info from those 20 columns display in 20 different textboxes on the form.

so i have connected to the database and checked to see if the name is in both tables but i can't get the result onto textboxes. how can i do that?

thank you.

VB.NET:
                'checking table 2
                Dim command2 As New OleDb.OleDbCommand("select * from far_inactive where fund_no = '" & txtSFund.Text & "'", command.Connection)
                Dim dr2 As OleDbDataReader = command2.ExecuteReader
                If dr2.HasRows = False Then
                    Exit Sub
                Else
                       
                    txtFundNo.Text = dr2.Item(1).value
 
First of all, you might want to read about command parameters (as I was reminded recently).

If you don't mind reading from both tables then you might be better using a union.

What is the actual problem that you are having in putting the result into the textboxes? You seem to have code for reading the results and accessing at least 1 field (although it is probably better to access it by field name than index, especially if you are using SELECT *).

You might find it easier using an Adapter and a DataTable.
 

Latest posts

Back
Top