[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
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
Re: DataGridview using ado.net
Re: DataGridview using ado.net
You're welcome. Please mark this thread `Resolved`.