After I pull information into the listbox, from the database, the operations no longer populate the text boxes when double clicked on. If the listbox is populated simply from doing calculations and saving them, then they can be clicked on. There is no error, simply nothing happens. I have tried using ListBox1.DataBindings.Clear() which doesn't seem to do anything, and ListBox1.DataSource.Clear and ListBox1.DataSource = Nothing, which simply causes the retrieve button to not work since as I understand it, it clears the source, which is populating the listbox.
Imports System.Data.OleDb
Module Module1
'global public variable
Public myDataSet As DataSet
'global public method
Public Sub GetData()
Dim cn As OleDbConnection = New OleDbConnection(" Provider=Microsoft.ACE.OLEDB.12.0;" +"Data Source=|DataDirectory|\CalcDB.accdb")
Dim cmd As OleDbCommand = New OleDbCommand("SELECT TOP 10 Operation FROM CalcOps", cn)
cn.Open()
Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
myDataSet = New DataSet()
myDA.Fill(myDataSet, "CalcOps")
cn.Close()
cn = Nothing
End Sub
End Module
Private Sub ButtonRet_Click(sender As Object, e As EventArgs) Handles ButtonRet.Click
Try
Call Module1.GetData()
If myDataSet.Tables.Count > 0 And myDataSet.Tables(0).Rows.Count > 0 Then
ListBox1.DataSource = myDataSet.Tables(0)
ListBox1.DisplayMember = "Operation"
End If
'Shows an error message with the problem message
Catch ex As Exception
MessageBox.Show("Error: " + ex.Message)
End Try
End Sub