0

hi
I have some questions in VB.Net

1- how can I retrieve data by VB.Net from database using MS Access database?
2- can I retrieve data from a database and list them in a CheckedListBox?

thanx

Please help me :-|

4
Contributors
3
Replies
7
Views
11 Years
Discussion Span
Last Post by durgeshmali1987
1

hi,

Here is the code to connect to the database in Ms Access.

Connection string for MS Access via OLE DB:

Dim connection As OleDbConnection
connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\NorthWind.mdb;User Id=;Password=;")

connection.Open();

After connecting to the database

dim da as new oledb.oledbdataadapter("select * from employees",connection)

dim ds as new dataset

da.fill(ds)

Now u can set the datas to the checked listbox.but u can assign only one column to it.

For eg

In checkedlistbox, u have a property items.

for i=0 to ds.tables(0).rows.count-1
Checkbox1.Items.Add(ds.tables(0).rows(i)(0)
next i

This will add all the rows with the first column values

Hope this helps

Regards

Exelio

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.