0

Pls see my code.Nothing is displaying in the grid

Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
          Dim connString As String = "Provider=SQLOLEDB;Data Source=MSALAMEEN;uid=sa;pwd=Sa1;Initial Catalog=Biometric"
        Dim myConnection As OleDbConnection = New OleDbConnection
        myConnection.ConnectionString = connString
        Dim da As OleDbDataAdapter = New OleDbDataAdapter("Select ID from bdata", myConnection)
        Dim ds As DataSet = New DataSet
        Dim dc1 As DataColumn = New DataColumn
        'da.Fill(ds)
        da.Fill(ds, "bdata")
        dc1 = ds.Tables("bdata").Columns("id")
        DataGridView1.DataSource = ds.DefaultViewManager
4
Contributors
4
Replies
6
Views
8 Years
Discussion Span
Last Post by samir_ibrahim
0

@jbisono: add this at the end. DataGridView1.DataBind()
No, It's not working. It is for ASP.NET.

DataGridView1.DataSource = ds.Table("bdata")
1

Pls see my code.Nothing is displaying in the grid

Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
          Dim connString As String = "Provider=SQLOLEDB;Data Source=MSALAMEEN;uid=sa;pwd=Sa1;Initial Catalog=Biometric"
        Dim myConnection As OleDbConnection = New OleDbConnection
        myConnection.ConnectionString = connString
        Dim da As OleDbDataAdapter = New OleDbDataAdapter("Select ID from bdata", myConnection)
        Dim ds As DataSet = New DataSet
        Dim dc1 As DataColumn = New DataColumn
        'da.Fill(ds)
        da.Fill(ds, "bdata")
        dc1 = ds.Tables("bdata").Columns("id")
        DataGridView1.DataSource = ds.DefaultViewManager

Try this,
After the last line add DataGridView1.DataMember = "bdata"

Votes + Comments
Yes, it is.
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.