Hey everyone, I know how to search for one specific number from a single line in an access database using a query, but now I have to search through a whole database and display each instance. Ex) I search the number "1" in column "1" of the database and it has "2" instances. So now I have to take the corresponding data in the rows next to it in order to display them in the label.
search: "1", both results are ID = "1"
results:
dates amount
10/13/2009 $43.00
12/25/2009 $86.00
I know how to put the results for "1" line of a database into the .item field, but im confused on how to search multiple lines of a database and store multiple items. Heres what I have so far...
Code:Private Sub btnShowPay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowPay.Click Dim targetid As String Dim dummy As Integer Dim selectstring As String Dim dates As String Dim amount As String Dim total As String If Not Integer.TryParse(txtID.Text.Trim, dummy) Then MessageBox.Show("member id must be integer") txtID.Focus() txtID.SelectAll() Exit Sub End If targetid = txtID.Text.Trim 'create select statement selectstring = "select * from payments where member_id = " & targetid 'find total amount of rows in database total = "select * from payments" 'create adapter memberadapter = New OleDb.OleDbDataAdapter(selectstring, connectionstring) 'create and fill the member data table membertable = New DataTable memberadapter.Fill(membertable) 'fill the data table 'check to see if a member was found or not If membertable.Rows.Count = 0 Then lblDispPay.Text = "id not found" Exit Sub End If lblDispPay.Text = "Dates Amount" ' extract data For x = 0 To CInt(total) Step 1 dates = CStr(membertable.Rows(x).Item(2)) amount = CStr(membertable.Rows(x).Item(3)) lblDispPay.Text &= dates & " " & amount Next x End Sub




Reply With Quote