Home » VB.NetRSS

Populate a DatagridView from an Access Database


I have an application in which I have to populate a datagridview from one table from an access database. Here is the code that I use to open and close .mdb file.



Public sql AsString
Public mydb AsObject
Public mylist AsObject
Public LOCATION_DB AsStringApplication.StartupPath() & "\training_plann_db.mdb"

mydb = CreateObject(


"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + LOCATION_DB + ";Jet Oledb:Database Password=lupucpr;")
sql =
" select * from employee_table "
mylist = mydb.execute(sql)


So, my question is, how can I populate dgv in this moment?
Can somebody help me, please?

I know that a way to populate is one by one in this way:

While mylist.eof=false
'''''' thing that will fill the row in datagridview'''

... But I don't want to use this way... I want a different way with a dataset or... I don't know.


2 Answers Found


Answer 1

A guess ...

Me.dgv_empl.DataSource = mylist

Hope this helps.


Answer 2

Here is code  I have used:


Then you would bind like this:

Me.dgv_empl.DataSource = dt

Hope this helps.


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter