Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Populate List Box from Access DB

$
0
0

I current have this code, when the button is clicked nothing happens. I suspect I'm either missing a connections or it's just entirely wrong. The DB is CalcDB, table is CalcOps, column is Operation. Needs to pull all of the rows into the list box.

Dim Builder As New OleDb.OleDbConnectionStringBuilder With
                    {
                        .Provider = "Microsoft.ACE.OLEDB.12.0",
                        .DataSource = IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CalcDB"),
                        .PersistSecurityInfo = False
                    }

        Try
            Using cn As New OleDb.OleDbConnection With {.ConnectionString = Builder.ConnectionString}
                Using cmd As New OleDb.OleDbCommand With {.Connection = cn}

                    cn.Open()

                    Dim comm As New OleDbCommand("SELECT Operation FROM CalcOps", cn)
                    comm.CommandType = CommandType.StoredProcedure
                    Dim da As New OleDbDataAdapter(comm)
                    Dim ds As New DataSet

                    da.Fill(ds)
                    ListBox1.Items.Clear()

                    If ds.Tables.Count > 0 And ds.Tables(0).Rows.Count > 0 Then
                        ListBox1.DataSource = ds
                    End If

                End Using
            End Using


        Catch ex As Exception

        End Try

           
    End Sub


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>