sozai
sozai

Reputation: 1

ADODB.Recordset data cannot bind into datagridview

i wan to bind data from recordset into data grid view, but the data cannot show in the grid view, i try count the row, there are 2 rows of data, but cannot bind into grid view

If Not rs.EOF Then                    
    DataGridView1.DataSource = rs
    DataGridView1.Refresh()
Else
    MsgBox("Record Not Founds  " & txtSearch.Text, MsgBoxStyle.OkOnly)
End If

Upvotes: 0

Views: 5516

Answers (2)

Matt Wilko
Matt Wilko

Reputation: 27322

@Stuart's answer is correct.

You could use the code on this site to convert your recordset to a datatable but note the problem I experienced here when I upgraded to .NET 4

Your best solution is to query your data with something that can handle datatables/datasets - what is your db?

Upvotes: 1

stuartd
stuartd

Reputation: 73253

You can't bind a DataGridView to an ADODB.Recordset. If you can't change the data source to ADO.Net then you will have to pre-process the recordset into something the DataGridView can bind to like a DataTable, or alternatively just write the rows in manually.

Upvotes: 2

Related Questions