+ All Categories
Home > Documents > Session 1

Session 1

Date post: 23-Oct-2014
Category:
Upload: vu-them
View: 29 times
Download: 5 times
Share this document with a friend
Popular Tags:
36
Manipulating Data in Windows Forms 1
Transcript
Page 1: Session 1

Manipulating Data in Windows Forms

1

Page 2: Session 1

Advanced Technologies in Windows Forms using C# / Session 1 2

Describe data tables and data views

Describe the use of CommandBuilder objects

Describe the process of managing changes to DataRow objects

Explain resolving of conflicts between a DataSet and a database

Describe the use of OleDbDataAdapter to access an ActiveX Data Objects (ADO) recordset or record

Objectives

Page 3: Session 1

DataTable objects: ADO.NET objects provide in-memory storage for the

data A single object constitutes one table of in-memory

data Often used as part of DataSet objects

Advanced Technologies in Windows Forms using C# / Session 1 3

Data Tables and Data Views 1-2

Visual representation of DataTable

Page 4: Session 1

4

Data Tables and Data Views 2-2

Windows Forms application

SQL Server Database

Connection EstablishedData retrieved and stored in memory within one or more DataSets

Data available for application through DataView

Advanced Technologies in Windows Forms using C# / Session 1

Page 5: Session 1

1. Create an SQL Server 2008 database, GradeSystem, and create a table Student as shown:

1. Add records into the table.2. Create a Windows Forms application named GradeSystem.

3. Rename the default form name and its class name to StudentForm and frmStudent respectively.

4. Add a DataGridView control to the form and rename it as dgvwStudentMarks.

An expression column - additional column added to a DataTable object

Can store results of calculations between existing columns Expression property of DataColumn class enables to create an

expression column Names of existing columns with one or more arithmetic

operators are supplied to the Expression property Arithmetic operators supported in expressions are:

Advanced Technologies in Windows Forms using C# / Session 1 5

Adding Expression Columns to DataTable objects 1-3

Operator Purpose

+ Addition

- Subtraction

* Multiplication

/ Division

% Modulus

Page 6: Session 1

6. Create a connection to the GradeSystem database.7. Add a data source using Data→Add New Data Source option. 8. Implement all the steps in the Data Source Configuration

Wizard. 9. Create a typed DataSet, GradeDataSet, based on the Student

table in SQL Server. 10. Switch to code view and add the namespace declaration in the

frmStudent class: using System.Data.SqlClient;

11. Add the following code at the beginning of the frmStudent class: GradeDataSet ds; GradeDataSetTableAdapters.StudentTableAdapter sta;

Advanced Technologies in Windows Forms using C# / Session 1 6

Adding Expression Columns to DataTable objects 2-3

Page 7: Session 1

12. Generate event handler for Load event of frmStudent and add the following code to it:

Advanced Technologies in Windows Forms using C# / Session 1 7

private void frmStudent_Load(object sender, EventArgs e)

{

ds = new GradeDataSet();

sta = new GradeDataSetTableAdapters.StudentTableAdapter();

sta.Fill(ds.Student);

DataColumn dc = new DataColumn("GrandTotal",

System.Type.GetType("System.Int16"));

dc.Expression = "Marks1 + Marks2 + Marks3";

ds.Student.Columns.Add(dc);

dgvwStudentMarks.DataSource = ds.Student;

}

Example

The new column is created using the DataColumn class and its data type is supplied as a parameter. The expression sums upthe values in the three marks columns. This column is added to the Student DataTable using the Add() method.

Output

Adding Expression Columns to DataTable objects 3-3

Page 8: Session 1

Properties of DataColumn class enable automatic incrementing of values in a column

Add following code to the Load event handler of the form:

Advanced Technologies in Windows Forms using C# / Session 1 8

Adding AutoIncrement Columns to DataTable objects 1-2

// create a variable to store the last student id value in the

// database table

int id;

// retrieve the last student id value

. . .

// create autoincrementing column

ds.Student.Columns["StudentID"].AutoIncrement = true;

ds.Student.Columns["StudentID"].AutoIncrementSeed = id + 1;

ds.Student.Columns["StudentID"].AutoIncrementStep = 1;

Snippet

The AutoIncrement property is set to true. This property determines if AutoIncrement should take place or not. The AutoIncrementSeed and AutoIncrementStep properties specify the starting value and the increment value respectively

Page 9: Session 1

When you attempt to add a new record in the DataGridView, the StudentID automatically increases to 104 as shown

Advanced Technologies in Windows Forms using C# / Session 1 9

Adding AutoIncrement Columns to DataTable objects 2-2

Page 10: Session 1

AcceptChanges()- commits the changes made

RejectChanges()- rolls back any changes that are made

These two methods can be called on a DataSet, DataTable, or even a DataRow

10

Accepting and Rejecting Changes to Data Tables

10

DataTable

New Row Added

AcceptChanges() is called

on the DataTableValue of RowState

property becomes “Added”

Row is committed and Value of RowState becomes “UnChanged”

Advanced Technologies in Windows Forms using C# / Session 1

RowState property of a DataRow

Page 11: Session 1

1. Add a new form to the Windows Forms application, GradeSystem.

2. Rename the form and its class to AddForm and frmAdd respectively.

3. Add five text boxes, five labels, and two buttons to the form.

Advanced Technologies in Windows Forms using C# / Session 1 11

Accepting and Rejecting Changes - Example 1-3

Page 12: Session 1

4. Set the properties of the controls as shown:

Advanced Technologies in Windows Forms using C# / Session 1 12

Control Property ValueLabel Name lblStudentID

Text Student IDLabel Name lblName

Text NameLabel Name lblMarks1

Text Marks in Test 1:Label Name lblMarks2

Text Marks in Test 2:Label Name lblMarks3

Text Marks in Test 3:TextBox Name txtID

Text ""TextBox Name txtName

Text ""TextBox Name txtMarks1

Text ""TextBox Name txtMarks2

Text ""Button Name btnAdd

Text Add

The form should look as follows:

Accepting and Rejecting Changes - Example 2-3

5. Add the following namespace declaration in the frmAdd class:

using System.Data.SqlClient;

6. Add the following code in the frmStudent class:

GradeDataSet ds;

GradeDataSetTableAdapters.StudentTableAdapter sta;

7. Double-click Add to generate a Click event handler.

Page 13: Session 1

Update() method of StudentTableAdapter object inserts successfully only if the SelectCommand or InsertCommand is set on the table adapter

In the current example, it is assumed that the commands are auto-generated by Visual Studio

Update() must be called before AcceptChanges() otherwise changes will not be committed to the database

8. Add the following code in the Click event handler:

Advanced Technologies in Windows Forms using C# / Session 1 13

private void btnAdd_Click(object sender, EventArgs e)

{

try

{

ds = new GradeDataSet();

sta = new GradeDataSetTableAdapters.StudentTableAdapter();

sta.Fill(ds.Student);

DataRow dr = ds.Student.NewRow();

dr["StudentID"]=txtID.Text;

dr["Name"]=txtName.Text;

dr["Marks1"]=txtMarks1.Text;

dr["Marks2"]= txtMarks2.Text;

dr["Marks3"] = txtMarks3.Text;

ds.Student.Rows.Add(dr);

sta.Adapter.Update(ds.Student);

ds.Student.AcceptChanges();

// Clear all the text fields

. . .

}

catch (Exception ex)

{

ds.RejectChanges();

}

}

Snippet

Accepting and Rejecting Changes - Example 3-3

In this code, a new data row is created using the NewRow() method of DataTable.

The newly added data is committed to the database through Update().

The data is also committed into the DataTable through AcceptChanges().

If an exception occurred at runtime, then RejectChanges()will help to roll back the changes.

Page 14: Session 1

Advanced Technologies in Windows Forms using C# / Session 1 14

DataView objects Enable to work with data tables in an easier manner Provide viewing, sorting, and filtering capabilities Enable you to traverse through related records from two

tables in a DataView

Primary condition - a DataRelation must exist between the two tables

Navigating Related Data in a DataView Object 1-4

Page 15: Session 1

Advanced Technologies in Windows Forms using C# / Session 1 15

Navigating Related Data in a DataView Object 2-4

Step by step procedure to create a DataView object and navigate related data in it:

1. Create a new table, StudentDetails, in the GradeSystem database. Student and StudentDetails are related to each other through a foreign key constraint on the StudentID column. Structure of StudentDetails is as shown

2. Add a few records into the StudentDetails table.3. Double-click GradeDataSet.xsd in the Solution Explorer in the

Visual Studio IDE.

Page 16: Session 1

16

Navigating Related Data in a DataView Object 3-4

Advanced Technologies in Windows Forms using C# / Session 1

10. Add the code shown to the frmView class:

GradeDataSet ds;

DataView dvwStud;

GradeDataSetTableAdapters.StudentTableAdapter sta;

GradeDataSetTableAdapters.StudentDetailsTableAdapter stda;

public frmView()

{

InitializeComponent();

ds = new GradeDataSet();

sta = new GradeDataSetTableAdapters.StudentTableAdapter();

stda = new

GradeDataSetTableAdapters.StudentDetailsTableAdapter();

sta.Fill(ds.Student);

stda.Fill(ds.StudentDetails);

}

Snippet

11. Generate Load event handler for the form and add the code shown:

private void frmView_Load(object sender, EventArgs e)

{

dvwStud = new DataView(ds.Student);

dgvwStudent.DataSource = dvwStud;

}

Snippet

Here, the DataSet and table adapter objects are instantiated. The DataSet is then populated with records from both tables through the Fill() method

Here, the DataView object is created based on the Student DataTable and then assigned to the DataSource property of the DataGridView

4. Open Server Explorer window by using View→Server Explorer.5. Drag and drop the StudentDetails table from the Server.

Explorer into the typed DataSet. Rename the auto-generated data relation as FK_StudentDetails.

6. Create a new form and name it as ViewForm. Rename the class to frmView.

7. Add a DataGridView to the form and name it as dgvwStudent.

8. Add another DataGridView to the form and name it as dgvwDetails.

9. Add a button with Text as Retrieve Details and name as btnRetrieve.

Page 17: Session 1

17

12. Generate Click event handler for the Retrieve Details button and add the code as shown:

Here, the DataView is first sorted. The row which owns the currently selected cell is searched. Based on this row and the data relation, child records are retrieved and added into a new DataView. This new DataView is then assigned to the second DataGridView.

private void btnRetrieve_Click(object sender, EventArgs e)

{

dvwStud.Sort = "StudentID";

int s = Convert.ToInt32(

dgvwStudent.SelectedCells[0].OwningRow.Cells["StudentID"].Value);

DataRowView drv = dvwStud[dvwStud.Find(s)];

DataView dvwStudDet = drv.CreateChildView(ds.Relations

["FK_StudentDetails"]);

dgvwDetails.DataSource = dvwStudDet;

}

Snippet

Advanced Technologies in Windows Forms using C# / Session 1

Output

Navigating Related Data in a DataView Object 4-4

Page 18: Session 1

For formatting and styling a DataGridView object using custom painting: Handle the CellPainting event and write custom

code in it. Set the e.Handled property to true.

18

Formatting a DataGridView using Custom Painting 1-3

Advanced Technologies in Windows Forms using C# / Session 1

Page 19: Session 1

Here, code is written to fill the grid area with LightYellow and then individual grid lines are drawn in Red

Also, the header row cells are painted in bold, and the rest of the cells are in normal style

The font name and size of the header rows are changed The various methods of Graphics class are used to perform

these operations

The complete step by step procedure is as follows:1. Revert to the Student Form created earlier.2. Generate an event handler for CellPainting event of the

DataGridView.

3. Add the code to the event handler:

19

Formatting a DataGridView using Custom Painting 2-3

private void dgvwStudentMarks_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)

{

e.Graphics.FillRectangle(Brushes.LightYellow, e.CellBounds);

e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Red)),

e.CellBounds);

if (e.Value != null)

{

Snippet

if (e.RowIndex >= 0)

{

Font font = e.CellStyle.Font;

string text = e.Value.ToString();

e.Graphics.DrawString(text, font, Brushes.Black,

e.CellBounds.X, e.CellBounds.Y);

}

else

{

Font font = new Font (e.CellStyle.Font,FontStyle.Bold);

e.Graphics.DrawString(e.Value.ToString(), font,

Brushes.Black, e.CellBounds.X,e.CellBounds.Y);

}

}

e.Handled = true;

}Advanced Technologies in Windows Forms using C# / Session 1

Page 20: Session 1

20

Output

Advanced Technologies in Windows Forms using C# / Session 1

Formatting a DataGridView using Custom Painting 3-3

Page 21: Session 1

Update() method of table adapter class inserts successfully only if SelectCommand or InsertCommand is set on the table adapter

To perform delete or modify operations, ensure that a SelectCommand, UpdateCommand, or DeleteCommand is set

A recommended workaround for this is to create a CommandBuilder object

A CommandBuilder object auto-generates the Insert, Update, and Delete commands

To use a CommandBuilder, a SELECT statement must be present in the SelectCommand and must return at least one primary key or unique column from the table

21

Using CommandBuilder 1-2

Advanced Technologies in Windows Forms using C# / Session 1

Page 22: Session 1

The code demonstrates the use of CommandBuilder. For an SQL Server database, the SqlCommandBuilder class is used

22

sta.Adapter.SelectCommand = new SqlCommand("SELECT * FROM Student",

sta.Connection);

sta.Connection.Open();

// Create the CommandBuilder object

SqlCommandBuilder sqlcomb = new SqlCommandBuilder(sta.Adapter);

// Retrieve the auto-generated commands and assign them

sta.Adapter.InsertCommand = sqlcomb.GetInsertCommand();

sta.Adapter.UpdateCommand = sqlcomb.GetUpdateCommand();

sta.Adapter.DeleteCommand = sqlcomb.GetDeleteCommand();

// Display the command text

MessageBox.Show(sta.Adapter.SelectCommand.CommandText);

MessageBox.Show(sta.Adapter.InsertCommand.CommandText);

MessageBox.Show(sta.Adapter.UpdateCommand.CommandText);

. . .

sta.Adapter.Update(ds.Student);

Snippet

Using CommandBuilder 2-2

Advanced Technologies in Windows Forms using C# / Session 1

In this code, the SelectCommand property of the adapter is set Then, an instance of SqlCommandBuilder is created with the

adapter The insert, update, and delete commands will be auto-generated

by the CommandBuilder They are retrieved and assigned to the respective properties of

the adapter object The newly assigned commands are displayed and the Update()

method is invoked to commit the changes to the database

Page 23: Session 1

Managing Changes to DataRow objects

Changes in row states are maintained by the enumerations, RowState and DataRowVersion

RowState property of a DataRow in a DataTable can have one of these values in the RowState enumeration:

23

Member Name DescriptionUnchanged Indicates that no changes are made since the last call to AcceptChanges()

or since the initial filling of the DataTableAdded Indicates that this row has been added since the last call to

AcceptChanges()Modified Indicates that this row has been updated since the last call to

AcceptChanges() Deleted Indicates that this row has been deleted from the DataTable since the last

call to AcceptChanges()Detached Indicates that this row has not yet been added to any DataTable.Rows

collection

Advanced Technologies in Windows Forms using C# / Session 1

The versions of the rows before and after changes are indicated by the members of DataRowVersion enumeration as shown in the table:

Member Name DescriptionOriginal Indicates that the row contains its original valuesCurrent Indicates that the row contains current valuesProposed Indicates that the row contains a proposed valueDefault Indicates the default version of DataRowState

Page 24: Session 1

24

Managing Changes to DataRow - Example 1-2

1. Add the code in the Load event handler of frmStudent:

This indicates that a method Student_ColumnChanged will handle the ColumnChanged event on the DataTable

2. Now, add the code shown in the class frmStudent:

private void Student_ColumnChanged(object sender, DataColumnChangeEventArgs e)

{

if (e.Row.HasVersion(DataRowVersion.Original))

{

// Compare the modified and original values

if (e.Row[e.Column.ColumnName].Equals(e.Row[e.Column.ColumnName, DataRowVersion.Original]))

{

MessageBox.Show("The original and the proposed values are

the same.");

Snippet

e.Row.RejectChanges();

}

else

{

MessageBox.Show("The original and the proposed values are

different.");

}

}

}

Advanced Technologies in Windows Forms using C# / Session 1

ds.Student.ColumnChanged += new DataColumnChangeEventHandler(

Student_ColumnChanged);

In this code, the argument, e, provides properties using which the row version and value in the changed column can be retrieved

If a new row is being added, there is no Original version for it Hence, the code first checks for the version If an Original version exists, it means the row is being modified Therefore, the proposed value for the column is compared with the original

value If they are same, a message is displayed to indicate that they are the same If they are different, a message is displayed to indicate that they are different

Page 25: Session 1

25

Managing Changes to DataRow - Example 2-2

3. Add a button with Text as Update, rename it as btnUpdate, and generate Click event for it

4. Add the code shown to the Click event handler of the button:

Here, the Update() method is called on the TableAdapter to send the changes to the database The in-memory DataTable is also committed through the AcceptChanges() method

private void btnUpdate_Click(object sender, EventArgs e)

{

sta.Adapter.Update(ds.Student);

ds.Student.AcceptChanges();

}

Advanced Technologies in Windows Forms using C# / Session 1

Output

The output shows the third record having modified name Kim Peters

Page 26: Session 1

MissingMappingAction

Determines the action to be taken when filling data into a DataSet or DataTable if there are no matching tables or column mappings Can be assigned to one of the values in the MissingMappingAction enumeration

Consider that some new columns are added to the table, but not in the DataSet. This may cause a conflict

You can resolve the conflict between the DataSet and the database by using following properties of the DataAdapter class:

MissingMappingAction MissingSchemaAction

26

Resolving Conflicts between a DataSet and a Database 1-5

Advanced Technologies in Windows Forms using C# / Session 1

Name DescriptionError Causes an InvalidOperationException to be thrown if the

DataAdapter tries to fill data in a column or table that does not existIgnore Ignores the non-matching data and discards it

Passthrough Creates the column(s) or table(s) in the DataSet and populates with the available data

Page 27: Session 1

Assume that a new form NewStudent is added to the application. Add a DataGridView control named dgvwStudentMarks to the form. Generate Load event for the form and add the following code to the handler:

Advanced Technologies in Windows Forms using C# / Session 1 27

private void frmNewStudent_Load(object sender, EventArgs e)

{

GradeDataSet ds;

GradeDataSetTableAdapters.StudentTableAdapter sta;

ds = new GradeDataSet();

sta = new GradeDataSetTableAdapters.StudentTableAdapter();

sta.Adapter.SelectCommand = new SqlCommand("SELECT * FROM Student",

sta.Connection);

sta.Connection.Open();

sta.Adapter.MissingMappingAction = MissingMappingAction.Error;

sta.Adapter.Fill(ds.Student);

dgvwStudentMarks.DataSource = ds.Student;

}

Snippet

Add a new column, Total, in the Student database:

Build and execute the code During execution, an InvalidOperationException is generated This is because of two reasons:

MissingMappingAction has been set to MissingMappingAction.Error Column mapping for Total is missing

Resolving Conflicts between a DataSet and a Database 2-5

Page 28: Session 1

Advanced Technologies in Windows Forms using C# / Session 1 28

Ignore new column and display the rest of the data

New column added results in conflict between DataSet and

database

Check other possibilities of MissingMappingAction

MissingMappingAction of DataAdapter

== MissingMappingAction.Ignore?

YesNo MissingMappingAction of DataAdapter

== MissingMappingAction.Passthrough

?

Add new column and display the rest of the data

Check other possibilities of MissingMappingAction

New column added results in conflict between DataSet and

database

YesNo

Resolving Conflicts between a DataSet and a Database 3-5

When the MissingMappingAction property value is Ignore

When the MissingMappingAction property value is Passthrough

Page 29: Session 1

29

Name DescriptionAdd Creates the column or table in the DataSet and populates with the available data

AddWithKey Creates the column, including any primary key information associated with the column, in the DataSet and populates it with the available data

Error Causes an InvalidOperationException to be thrown if the DataAdapter attempts to fill data in a column or table that does not exist

Ignore Ignores the non-matching data and discards it

Advanced Technologies in Windows Forms using C# / Session 1

MissingSchemaAction Determines the action to be taken when filling data into a DataSet or DataTable if there is no expected schema

present Can be assigned to one of the values in the MissingSchemaAction enumeration

Resolving Conflicts between a DataSet and a Database 4-5

Page 30: Session 1

The code demonstrates how to use the MissingMappingAction property of the DataAdapter

30

private void frmNewStudent_Load(object sender, EventArgs e)

{

GradeDataSet ds;

GradeDataSetTableAdapters.StudentTableAdapter sta;

ds = new GradeDataSet();

sta = new GradeDataSetTableAdapters.StudentTableAdapter();

sta.Adapter.SelectCommand = new SqlCommand("SELECT * FROM Student",

sta.Connection);

sta.Connection.Open();

sta.Adapter.MissingSchemaAction = MissingSchemaAction.Error;

// Create a dummy DataSet

DataSet dset = new DataSet();

sta.Adapter.Fill(dset);

dgvwStudentMarks.DataSource = ds.Student;

}

Snippet

When the code is executed, an InvalidOperationException is generated

This is because of two reasons: MissingSchemaAction property of the DataAdapter is set to

MissingSchemaAction.Error The DataTable, Student, is missing in the DataSet

In the same code, if you specify MissingSchemaAction.AddWithKey, the Student table will be added to the DataSet with the primary key

Advanced Technologies in Windows Forms using C# / Session 1

Resolving Conflicts between a DataSet and a Database 5-5

Page 31: Session 1

Advanced Technologies in Windows Forms using C# / Session 1 31

ADO Easy connectivity and data handling features Relies on a connected architecture and needs a constant

connection ADO.NET

Based on the principle of disconnected architecture. Faster, reliable, and more efficient solution to data access

To access an ADO recordset or record from a data source such as Microsoft Access or SQL Server 2000 database, you can use an OleDbDataAdapter object

Using OleDbDataAdapter to access an ADO Recordset or Record 1-4

Step by step procedure:1. Create a Windows Forms application named ADODemo.2. Rename the default form to ContactForm and class to

frmContacts.

3. Include the following namespace declaration in the class: using System.Data.OleDb;4. Select Project→Add Reference to add a reference to the ADO

objects.5. Select the COM tab.

Page 32: Session 1

Advanced Technologies in Windows Forms using C# / Session 1 32

6. Select Microsoft ActiveX Data Objects 2.8 Library as shown and click OK.

7. Add a new method GetRecordset that returns a value of type ADODB.Recordset:

A connection is established to the Microsoft Access database named Contacts. Then, a new recordset object named rs is created and opened. The cursor type is set to adOpenStatic. A SELECT query is passed as one of the parameters to the Open() method to retrieve all the records.

private ADODB.Recordset GetRecordset()

{

string con = "Provider=Microsoft.Jet.OLEDB.4.0;Data

Source=f:\\Contacts.mdb;";

ADODB.Recordset rs= new ADODB.Recordset();

rs.Open("SELECT * FROM Contacts", con,

ADODB.CursorTypeEnum.adOpenStatic,

ADODB.LockTypeEnum.adLockBatchOptimistic, 0);

return rs;

}

Snippet

Using OleDbDataAdapter to access an ADO Recordset or Record 2-4

Page 33: Session 1

8. Add a DataGridView and a button to the form. 9. Set their properties as shown:

10. Add following code for the Click event handler of the button:

Here, a DataTable is created and filled through an instance of OleDbDataAdapter. The method GetRecordset() created earlier is passed as a parameter to the Fill() method. The data table that is populated is then assigned to the DataGridView.

Advanced Technologies in Windows Forms using C# / Session 1 33

Control Property Value

DataGridView Name dgvwContacts

Button Name btnFill

Text Fill

private void btnFill_Click(object sender, EventArgs e)

{

DataTable contactsTable = new DataTable("Contacts");

OleDbDataAdapter adapter = new OleDbDataAdapter();

adapter.Fill (contactsTable, GetRecordset());

dgvwContacts.DataSource = contactsTable;

}

Using OleDbDataAdapter to access an ADO Recordset or Record 3-4

Page 34: Session 1

11. Build and execute the application.

Advanced Technologies in Windows Forms using C# / Session 1 34

Output

Using OleDbDataAdapter to access an ADO Recordset or Record 4-4

Similarly, an OleDbDataAdapter object can also be used with SQL Server 2000 databases to retrieve ADO recordsets

Page 35: Session 1

Summary 1-2

The Expression property of the DataColumn class is used to create an expression column.

The AutoIncrement and other properties of the DataColumn class enable to create autoincrementing columns in a table.

The AcceptChanges() and RejectChanges() methods allow changes made to a DataTable to be accepted or rejected respectively.

You can navigate related records from two tables in a DataView, provided that a DataRelation exists between the two tables.

A DataGridView object can be formatted by using custom painting.

35Advanced Technologies in Windows Forms using C# / Session 1

Page 36: Session 1

Summary 2-2

A CommandBuilder object is used to auto-generate the Insert, Update, and Delete commands.

The MissingMappingAction and MissingSchemaAction properties of DataAdapter class enable to resolve conflicts between a DataSet and a database.

The OleDbDataAdapter object helps to access an ADO recordset or record.

36Advanced Technologies in Windows Forms using C# / Session 1


Recommended