[code]Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Using connection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\rose&mike\Desktop\DbSysDel3\salondbaccess.accdb"),
adapter As New OleDbDataAdapter("SELECT Service_Name, Service_Fee FROM [Service_Types]", connection)
Dim sql As String = "Select Lastname FROM Employees2"
Dim cmd As New OleDbCommand
cmd = New OleDb.OleDbCommand(sql, connection)
connection.Open()
Dim dr As OleDbDataReader = cmd.ExecuteReader
If dr.HasRows Then
While dr.Read
chcklstbx2.Items.Add(dr(0))
End While
End If
Dim table As New DataTable
adapter.Fill(table)
With chcklstbx1
.DataSource = table
.DisplayMember = "Service_Name"
.ValueMember = "Service_Fee"
End With
connection.Close()
End Using
End Sub[/code]
How to save data from checkedlistbox to access database?
Hello. I'm having trouble with inserting data to a database based on items checked on a checkedlistbox. There are two and the data on the checkedlistboxes are also from the same database but from different tables and they will serve as foreign keys to the table where I need to save them. I need it so that when the user finishes selecting the items and click the button, it would instantly save it to the database. Here is the code that I use to get the data from the database for both checkedlistboxes: