Hi, I Am having Problems Getting The Listbox To Bind With The DataTable.
i have tried quite a few diffrent bits of code, far to many to list them all, so just an example of what i mean
Code:
ListBox_Recent.DisplayMember = "InvoiceName"
ListBox_Recent.DataSource = table
again im not getting any errors but i am getting this agian
Untitled.png
could you please give me the proper Code To Bind The Datatable To The Listbox, I Have Googled And All examples Are not Working
Here Is All Involved Code
Code:
#Region "Recent Work"
Private connection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\DB.accdb;Persist Security Info=True")
Private table As New DataTable
Public Sub RecentWork_Display()
Using connection
connection.Open()
Using command As New OleDbCommand("SELECT * FROM RecentWork", connection)
Using reader As OleDbDataReader = command.ExecuteReader()
table.Load(reader)
End Using
End Using
End Using
End Sub
Public Sub RecentWork_add(InvoiceName As String)
Dim insert As New OleDbCommand("INSERT INTO RecentWork (InvoiceName, DateCreated, DeleteDate) " & "VALUES (@InvoiceName, @DateCreated, @DeleteDate)", Me.connection)
connection.Open()
With insert.Parameters
.AddWithValue("@InvoiceName", InvoiceName)
.AddWithValue("@DateCreated", Format(Date.Today, "dd:MM:yyyy"))
.AddWithValue("@DeleteDate", Format(DateAdd(DateInterval.Day, 10, Date.Today), "dd:MM:yyyy"))
End With
insert.ExecuteNonQuery()
connection.Close()
End Sub
Public Sub RecentWork_Delete(InvoiceName As String)
Dim delete As New OleDbCommand("DELETE FROM RecentWork WHERE InvoiceName = @InvoiceName", Me.connection)
connection.Open()
delete.Parameters.AddWithValue("@InvoiceName", InvoiceName)
delete.ExecuteNonQuery()
connection.Close()
End Sub
Public Sub RecentWork_Keep(InvoiceName As String)
Dim update As New OleDbCommand("UPDATE RecentWork SET DeleteDate='00:00:0000', InvoiceName = @InvoiceNameK WHERE InvoiceName= @InvoiceName'", connection)
connection.Open()
With update.Parameters
.AddWithValue("@InvoiceNameK", InvoiceName & " (K)")
.AddWithValue("@InvoiceName", InvoiceName)
End With
update.ExecuteNonQuery()
connection.Close()
End Sub
Bookmarks