Public Class Form1
'START OF DATABASE OPERATION!!!!!!
Private Sub btnGetCustomerNames_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetCustomerNames.Click
Dim strConnectionString As String = "Provider = Microsoft.Ace.OLEDB.12.0;" & _
"Data Source = F:/MyFolder/Filters.accdb "
Dim MyConnection As New OleDb.OleDbConnection(strConnectionString)
MyConnection.Open()
Dim MyCommand As New OleDb.OleDbCommand("SELECT * FROM customers", MyConnection)
Dim MyDataSet As New Data.DataSet
Dim MyDataAdapter As New OleDb.OleDbDataAdapter(MyCommand)
MyDataAdapter.Fill(MyDataSet, "QueryResults")
MyConnection.Close()
'END OF DATABASE OPERATION!!
LstCustomerNames.DataSource = MyDataSet.Tables("QueryResults")
LstCustomerNames.DisplayMember = "FirstName"
LstCustomerNames.ValueMember = "CustomerID"
End Sub
End Class
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment