简体   繁体   中英

How can i load DataGridView?

I'm Having Ms Access table Actionpoint with four rows. and i am trying to load that in the grid view using the following code

Dim dt as DataTable
Dim da as New OleDbDataAdapter
con.Open()
da = New OleDbDataAdapter("SELECT * FROM ActionPoint",con)
da.fill(dt)
GridView1.datasource = dt.DefaultView

But it loads only a empty row. What is the wrong in this code? How can i resolve?

Change this line

GridView1 = dt.DefaultView

to

GridView1.DataSource = dt

try this one:

Dim dt as new DataTable
Dim da as New OleDbDataAdapter
con.Open()
da = New OleDbDataAdapter("SELECT * FROM ActionPoint",con)
da.fill(dt)

GridView1.datasource = dt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM