Bishnu Dev Bishnu Dev - 2 months ago 26 Question

Displaying SQLite Data In DataGridView

I am using sqlite database and using i am trying to print some rows in datagridview. I use the following code:

Public Sub LoadUsername()
Dim ConnectionString As String = "Data Source=info.sqlite"
Dim nSQL As String = "SELECT Name From employee"
Dim dt As DataTable = Nothing
Dim ds As New DataSet

Using con As New SQLiteConnection(ConnectionString)
Using cmd As New SQLiteCommand(nSQL, con)
Using da As New SQLiteDataAdapter(cmd)

dt = ds.Tables(0)
End Using
End Using
End Using

ListBox1.ValueMember = "Name"
ListBox1.DisplayMember = "FullName"
ListBox1.DataSource = dt

Catch ex As Exception

End Try

End Sub

but when i execute or compile this program, it shows me System.Data.DataRowView in the field where name should be. please check the image. Thanks!

enter image description here


There is no FullName column in your datatable yet that's what you're trying to bind the display to. Change the DisplayMember to Name as it should work correctly.

System.Data.DataRow is just the default ToString implementation as it cant find your fullname property.