Results 1 to 4 of 4

Thread: [RESOLVED] DataGridview using ado.net

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2007
    Posts
    228

    Resolved [RESOLVED] DataGridview using ado.net

    Hi guys

    Im busy learning ado.net. This is my code

    Code:
    Public Class Form1
        Private CN As New OleDbConnection
        Private DataAdapter As OleDbDataAdapter
        Private CommandBuilder As OleDbCommandBuilder
        Private KeyGen As New DataTable
        Private RowPosition As Integer
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            CN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\KeyGenTruckSpecs.mdb"
            CN.Open()
            DataAdapter = New OleDbDataAdapter("SELECT * FROM KeyGen", CN)
            CommandBuilder = New OleDbCommandBuilder(DataAdapter)
                   DataAdapter.Fill(KeyGen)
        End Sub
    End Class
    I cant bind the datagridview to a table. How will i go on doing that?
    using vb.net

    Regard
    Gerald

  2. #2
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    UK
    Posts
    285

    Re: DataGridview using ado.net

    You seem to have done everything except set the datasource of the datagridview to your datatable...!

    DataGridView1.DataSource=KeyGen
    DataGridView1.DataMember=KeyGen.TableName

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2007
    Posts
    228

    Re: DataGridview using ado.net

    Thank you.

  4. #4
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    UK
    Posts
    285

    Re: DataGridview using ado.net

    You're welcome. Please mark this thread `Resolved`.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width