All pastes #474649 Raw Edit

Mine

public text v1 · immutable
·published 2007-05-06 22:52 UTC
rendered paste body
Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim objOleDbConnection As OleDbConnection
    Dim objOleDbCommand As OleDbCommand
    Dim dr As OleDbDataReader
    Dim strProdName As String

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents cmbColor As System.Windows.Forms.ComboBox
    Friend WithEvents cmbManufacturer As System.Windows.Forms.ComboBox
    Friend WithEvents btnSearch As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.btnSearch = New System.Windows.Forms.Button
        Me.cmbManufacturer = New System.Windows.Forms.ComboBox
        Me.cmbColor = New System.Windows.Forms.ComboBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label1 = New System.Windows.Forms.Label
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.btnSearch)
        Me.GroupBox1.Controls.Add(Me.cmbManufacturer)
        Me.GroupBox1.Controls.Add(Me.cmbColor)
        Me.GroupBox1.Controls.Add(Me.Label2)
        Me.GroupBox1.Controls.Add(Me.Label1)
        Me.GroupBox1.Location = New System.Drawing.Point(48, 40)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(392, 208)
        Me.GroupBox1.TabIndex = 0
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "Search Criteria"
        '
        'btnSearch
        '
        Me.btnSearch.Location = New System.Drawing.Point(136, 152)
        Me.btnSearch.Name = "btnSearch"
        Me.btnSearch.Size = New System.Drawing.Size(120, 32)
        Me.btnSearch.TabIndex = 4
        Me.btnSearch.Text = "Search Table"
        '
        'cmbManufacturer
        '
        Me.cmbManufacturer.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cmbManufacturer.Items.AddRange(New Object() {"Sony", "Aiwa", "Panasonic", "Toshiba"})
        Me.cmbManufacturer.Location = New System.Drawing.Point(168, 104)
        Me.cmbManufacturer.Name = "cmbManufacturer"
        Me.cmbManufacturer.Size = New System.Drawing.Size(192, 21)
        Me.cmbManufacturer.TabIndex = 3
        '
        'cmbColor
        '
        Me.cmbColor.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cmbColor.Items.AddRange(New Object() {"Black", "White", "Grey", "Beige"})
        Me.cmbColor.Location = New System.Drawing.Point(168, 32)
        Me.cmbColor.Name = "cmbColor"
        Me.cmbColor.Size = New System.Drawing.Size(192, 21)
        Me.cmbColor.TabIndex = 2
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(24, 104)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(112, 32)
        Me.Label2.TabIndex = 1
        Me.Label2.Text = "Manufacturer"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(24, 32)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(112, 32)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Color"
        '
        'Form1
        '
        Me.AcceptButton = Me.btnSearch
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(496, 302)
        Me.Controls.Add(Me.GroupBox1)
        Me.Name = "Form1"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Product List Search"
        Me.GroupBox1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    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
                objOleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Documents and Settings\Administrator\Desktop\Course Technology\65471\Data Files for Students- Version 2002\Chapter10")
                objOleDbCommand.Connection = objOleDbConnection
                objOleDbConnection.Open()
                objOleDbCommand = New OleDbCommand("SELECT * FROM ProductList WHERE Color = cmbColor.Text AND Manufacturer = cmbManufacturer.Text", objOleDbConnection)
                'objOleDbCommand.CommandText = "SELECT * FROM ProductList WHERE Color = cmbColor.Text AND Manufacturer = cmbManufacturer.Text, objOleDbConnection"
                dr = objOleDbCommand.ExecuteReader
                Do While dr.Read
                    MessageBox.Show("ProductName" & dr(0).ToString)
                Loop
                dr.Close()
                objOleDbConnection.Close()
            Catch er As Exception
            End Try
        End If
    End Sub
End Class