Question .Net & Access

lostwages702

New member
Joined
Nov 1, 2010
Messages
3
Programming Experience
3-5
Hello everyone... I am hoping that I can find some help here as I have been at a loss the last few days while trying to write a new program for myself.

I have a MS Access database file from which I am trying to gather some data. Currently when my form loads, I have it connect to the DB as shown:

VB.NET:
Dim PPConnect As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Subs.accdb")
    Dim PPCommand As OleDbCommand
    Dim PPReader As OleDbDataReader

Public Sub PPGetSubs()
        Try
            PPConnect.Open()
            PPCommand = New OleDbCommand("SELECT * FROM Subs", PPConnect)
            PPReader = PPCommand.ExecuteReader
            While PPReader.Read
                ComboBox1.Items.Add(PPReader(1))
            End While
        Catch
        End Try
        PPReader.Close()
        PPConnect.Close()
    End Sub

That currently populates my ComboBox1 correctly with all of my subs, but where I am getting lost is my next step. Depending upon which Subs is selected, I need to pull all items from my Lots table that are linked to the select Sub... Hope that makes sense. To do so, I have the following setup:

VB.NET:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedValueChanged
        PPGetLots()
    End Sub

Public Sub PPGetLots()
        Try
            PPConnect.Open()
            Dim PPCurSub As String = ComboBox1.Text
            Dim PPLotStr As String = "SELECT * FROM Lots WHERE Subs='" & PPCurSub & "'"
            PPCommand = New OleDbCommand("SELECT * FROM Lots WHERE Subdivisions='" & PPCurSub & "'", PPConnect)
            PPReader = PPCommand.ExecuteReader
            Do While PPReader.Read
                ComboBox2.Items.Add(PPReader(1))
            Loop
        Catch
        End Try
        PPReader.Close()
        PPConnect.Close()
    End Sub

This is where things stop working for me. I thought that this would properly populate my CB2, but it is not doing anything at all for me. Where am I going wrong as I have tried re-writing this several times to no avail. Please help so I don't pull out the remaining hair on my head :D.

Thanks in advance. If you need me to provide more of my code, please let me know.
 
Back
Top