|
|
Title | Use compiled-in data with ADO.NET |
Keywords | VB.NET, NET, DataGrid, ADO.NET, inline data, compiled-in data |
Categories | Database, VB.NET |
|
|
Create a new DataSet. Add a new DataTable to the DataSet. Define the DataTable's columns.
Now populate the DataTable and bind the table to a DataGrid.
|
|
Private m_DataSet As DataSet
Private m_dtPeople As DataTable
' Create some data and bind it to the DataGrid.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles MyBase.Load
' Build the DataSet.
m_DataSet = New DataSet()
' Build the People table.
m_dtPeople = New DataTable("People")
m_DataSet.Tables.Add(m_dtPeople)
m_dtPeople.Columns.Add("LastName", GetType(String))
m_dtPeople.Columns.Add("FirstName", GetType(String))
m_dtPeople.Columns.Add("Email", GetType(String))
' Populate the People table.
Dim people_data(2) As String
people_data(0) = "Jennie"
people_data(1) = "Simpson"
people_data(2) = "JennieSimpson@dev.null.com"
m_dtPeople.Rows.Add(people_data)
people_data(0) = "Nik"
people_data(1) = "Oswald"
people_data(2) = "Nik@SomewhereElse.com"
m_dtPeople.Rows.Add(people_data)
' Add other records ...
' Bind the DataGrid to the DataTable.
dgPeople.DataSource = m_dtPeople
End Sub
|
|
|
|
|
|
|
|