Need some help,
I'm using vb2008
oledb connection
I have one table in an access database with 4 important fields to find the result of a search through combobox selection.
EX.
combobox1 query on form load fills combobox1 with YEAR selection from database.
VEHICLEDATA database has fields of YEAR, MAKE, MODEL, ENGINE, FILTERNUMBER, ENGINECAPACITY.
as you can see we are looking up oil filter numbers by
vehicle application.
User selects the YEAR first from combobox1, the next step I can't quite figure the query....
Using combobox1 click event need to query for combobox2 to load its values based on a progressive type query.
i'm not real familiar with select statement, could someone help.
Eventually i want to fill remaining comboboxes for selection
progressively.
select year, select make, select model, select engine.
this order will eventually retreive the oil filter number and engine oil capacity from the database
This is the current code:
Imports System.Data.OleDb
Public Class Form1
Inherits System.Windows.Forms.Form
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Load combobox1 with year data for initial start
Try
cn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\VehicleData.accdb")
cn.Open()
cmd = New OleDbCommand("SELECT DISTINCT [Year] FROM(VehicleData) ORDER BY [Year] DESC", cn)
dr = cmd.ExecuteReader
While dr.Read
ComboBox1.Items.Add(dr(0))
End While
Catch
End Try
dr.Close()
cn.Close()
'End combobox1 initial load
End Sub
End Class
I'm using vb2008
oledb connection
I have one table in an access database with 4 important fields to find the result of a search through combobox selection.
EX.
combobox1 query on form load fills combobox1 with YEAR selection from database.
VEHICLEDATA database has fields of YEAR, MAKE, MODEL, ENGINE, FILTERNUMBER, ENGINECAPACITY.
as you can see we are looking up oil filter numbers by
vehicle application.
User selects the YEAR first from combobox1, the next step I can't quite figure the query....
Using combobox1 click event need to query for combobox2 to load its values based on a progressive type query.
i'm not real familiar with select statement, could someone help.
Eventually i want to fill remaining comboboxes for selection
progressively.
select year, select make, select model, select engine.
this order will eventually retreive the oil filter number and engine oil capacity from the database
This is the current code:
Imports System.Data.OleDb
Public Class Form1
Inherits System.Windows.Forms.Form
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Load combobox1 with year data for initial start
Try
cn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\VehicleData.accdb")
cn.Open()
cmd = New OleDbCommand("SELECT DISTINCT [Year] FROM(VehicleData) ORDER BY [Year] DESC", cn)
dr = cmd.ExecuteReader
While dr.Read
ComboBox1.Items.Add(dr(0))
End While
Catch
End Try
dr.Close()
cn.Close()
'End combobox1 initial load
End Sub
End Class