Date post: | 04-Jan-2016 |
Category: |
Documents |
Upload: | marvin-greer |
View: | 250 times |
Download: | 2 times |
1
Data Classes- DataViewData Classes- DataViewDataGridView ControlDataGridView Control
Objectives
2
Data Class DataAdapter DataReader DataSet DataTable
DataView DataGridView Control Summary
DataAdapter Properties
3
Demo
4
SqlDataAdapter is the best way to load data from server to DataSet
SqlDataAdapter : properties - Events
5
SqlDataAdapter dataAdapt = new SqlDataAdapter();SqlCommand cmd = new SqlCommand(“Select * from authors” , con);dataAdapt.SelectCommand = cmd ; DataSet ds = new DataSet();dataAdapt.Fill(ds);
DeleteCommand
InsertCommand
SelectCommand
UpdateCommand
RowUpdate
RowUpdating
OleDbDataAdapter
6
Used to connect to multiple databses such as : SQLServer , Access , Oracle Exists in the namespace : System.Data.OleDb Have the same properties and events as SqlDataAdapter
SqlDataReader class
7
• Used to read data from SQL Server in a sequential manner and have some properties :
• Forward-only - Read Only• Get it by call the ExecuteReader() method of SqlCommand object• Read data by Read() method
FieldCount
HasRow
IsClosed
Item
RecordsAffected
SqlDataReader : Method
8
DataSet
9
• A representation of a database in cached-memory• Included datatable and relation and contrains Ex : DataSet ds = new DataSet()
Method – Kind of DataSet
10
TypeDataSet :-Have a schema : .xsd
UntypeDataSet :-Create by a code :DataSet A = new DataSet()
Navigate Record :Using Binding source class and use some methods of this class as :
- MoveFirst- MoveLast- MoveNext- MovePrevious
DataSet and XML
11
DataSet can fetch data from a XML file• ReadXML(string path) : read XML file to DataSet• WriteXML(string path) : save the content DataSet to a XML file
DataTable class
12
• Represent a table in DataSet• Have a constraint objects that ensure data integrity
Properties
Method
13
DataTable: Event
14
DataTableCollection
15
• The DataTableCollection class is a collection of the tables in DataSet• Collection of the DataTable class
DataRelation
16
• Maintains referential integrity by enforcing foreign-key constraint• Unique constraint• Cascade update and delete operation• Use to relate two DataColumn Object that exits in two DataTable
DataColumn class
17
• Used for creating a schema for a particular column • You can add a column to a DataColumnCollection
DataRow class
18
Represent a row in a DataTable
DataTableReader
19
DataTableReader
20
DataTableReader dtr = dataTable.CreateDataReader()
Demo
21
Summary
22
Data Class DataAdapter DataReader DataSet DataTable
DataView class
23
Used to sort , filter , search , modify and navigate through the recordConstructor of this class is a dataTable
Properties
24
25
DataViewManager
26
DataGrid control
27
• Display data in a tabular format• Populated by the table present in dataSet ( binding)• Insert , delete , update DataSet
DataGridView control
28
DataGridView control
29
Example
30
DataGridView & DataGrid control
31
Summary
32