Dim objOleDbConnection As OleDbConnection
Dim objOleDbCommand As OleDbCommand
Dim objOleDbDataReader As OleDbDataReader
Dim strSQL As String
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
If cmbColor.SelectedIndex = -1 Then
MessageBox.Show("Please select a color", "No Color Selected!")
ElseIf cmbManufacturer.SelectedIndex = -1 Then
MessageBox.Show("Please select a manufacturer", "No Manufacturer Selected!")
Else
Try
objOleDbCommand.Connection = objOleDbConnection
MessageBox.Show("Database has been opened")
objOleDbCommand.Connection.Open()
strSQL = "SELECT ProductName FROM ProductName " & _
"WHERE Color = cmbColor.Text " & _
"AND Manufacturer = cmbManufacturer.Text"
objOleDbCommand.CommandText = strSQL
objOleDbDataReader = objOleDbCommand.ExecuteReader
Do While (objOleDbDataReader.Read())
MessageBox.Show(Convert.ToString(objOleDbCommand))
Loop
objOleDbDataReader.Close()
objOleDbConnection.Close()
Catch er As Exception
End Try
End If
End Sub