Navigation bar
  Print document Start Previous page
 65 of 90 
Next page End  

Gravitybox Schedule.NET
1998-2005 Gravitybox Software LLC
Page 63 of 90
Chapter 8
Data Binding
Overview
Data binding is the process of binding a schedule directly to a dataset. VS.NET defines
an object named Dataset. This object can effectively hold multiple database tables. This
discussion assumes that you have used datasets before.
Since every application has its own structure and data, you may think that it would be
impossible to bind a schedule to an unknown database. The schedule is quite flexible in
that it can bind to a dataset with minimal data. In addition a dataset can be expanded to
encompass many optional fields. There are also some other constraints on the dataset
structure to make it compatible with the schedule. However none of these are
overbearing and you can create a compatible dataset from your database quite easily.
A dataset can be defined visually using the Visual Studio environment. In this fashion
you can create a strongly typed dataset with appropriate columns and constraints. You
can view the dataset on screen and modify it. A strongly typed dataset is derived from
the “System.Data.Dataset” object. Alternatively you can create a dataset in code. This
second method is described in the example below.
When creating the dataset there are a few constraints on its structure. First, there must
be a table defined in the dataset named “Appointment”. This table must contain the
columns Appointment_Guid, StartDate, StartTime, and Length with the data types
string, date, date, and integer respectively. All of these columns must be marked to
disallow DbNull and the Appointment_Guid column must be marked as unique. This is
the minimal set of requirements. If any of these requirements are not met, the schedule
will throw an error when the dataset is bound.
The following code snippet defines a minimal dataset in code.
'Create a dataset with an "Appointment" table
Dim ds As New System.Data.DataSet
Dim dt As System.Data.DataTable = ds.Tables.Add("appointment")
'Create the necessary columns
dt.Columns.Add("appointment_guid", GetType(String))
dt.Columns.Add("start_date", GetType(Date))
dt.Columns.Add("start_time", GetType(Date))
dt.Columns.Add("length", GetType(Integer))
'Mark to disallow DBNull
dt.Columns("appointment_guid ").AllowDBNull = False
dt.Columns("start_date").AllowDBNull = False
dt.Columns("start_time").AllowDBNull = False
dt.Columns("length").AllowDBNull = False
http://www.purepage.com