Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleDefine a DataSet at design time in Visual Basic 2005
DescriptionThis example shows how to define a DataSet at design time in Visual Basic 2005.
KeywordsDataSet, design time, VB.NET, Visual Basic 2005
CategoriesVB.NET, Database
 
To create a DataSet class at design time:

  1. Create a new project.
  2. From the Projects menu, select Add New Item, select DataSet, give the data set type a good name (such as PeopleDataSet), and click OK.
  3. From the Toolbox's DataSet tab, drag a DataTable onto the DataSet. Use the Properties window to give it a good name (such as dtPeople).
  4. Right-click on the DataTable, open the context menu's Add submenu, and select Column. Give the new column a name. Then use the Properties window to set the column's properties (DataType, DefaultValue, MaxLength, and so forth).

Now your code can create instances of this type of DataSet. The following code creates an instance of the DataSet, adds data to its table, and then makes the program's DataGridView control use the table as a data source.

 
' Make a DataSet and add some records to it.
Dim ds As New PeopleDataSet()
ds.dtPeople.Rows.Add("Alice", "Archer", "111 Ash Ave", _
    "Ashland", "KY", "11111", "111-111-1111")
ds.dtPeople.Rows.Add("Ben", "Butter", "222 Beach Blvd", _
    "Bend", "OR", "22222", "222-222-2222")
ds.dtPeople.Rows.Add("Cindy", "Concert", "333 Cedar Ct", _
    "Cinderblock", "NV", "33333", "333-3333")

' Attach the DataSet to the table.
dgvPeople.DataSource = ds.dtPeople
 
 
Copyright © 1997-2006 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated