Page 104 - DCAP312_WEB_TECHNOLOGIES_II
P. 104

Web Technologies-II



                   Notes                                  Figure 5.2: DataSet Architecture


                                                                    DATASET


                                                         Data Table Collections
                                                         Data Table
                                                                Data Row Collection

                                                             Data D Coloumn Collection
                                                               Constraint Collection




                                                               Data Relation Collection




                                 The Dataset contains the copy of the data we requested. The Dataset contains more than one
                                 Table at a time. We can set up Data Relations between these tables within the DataSet. The
                                 data set may comprise data for one or more members, corresponding to the number of rows.
                                 The DataAdapter object allows us to populate DataTables in a DataSet. We can use Fill method
                                 of the DataAdapter for populating data in a Dataset. The DataSet can be filled either from a
                                 data source or dynamically. A DataSet can be saved to an XML file and then loaded back into
                                 memory very easily.

                                 5.6 ADO.NET DataReader

                                 DataReader Object in ADO.NET is a stream-based, forward-only, read-only retrieval of query
                                 output from the Data Sources, which do not update the data. The DataReader cannot be shaped
                                 directly from code; they can make only by calling the ExecuteReader process of a Command
                                 Object.


                                                          Figure 5.3: DataReader Hierarchy

                                                                  Data Reader
                                                                   Command

                                                                   Connection

                                                                   Data Source

                                 SqlDataReader sqlReader = sqlCmd.ExecuteReader();

                                 The DataReader Object provides an association oriented data entrée to the Data Sources.
                                 A Connection Object can contain only one DataReader at a time and the connection in the
                                 DataReader remains open, also it cannot be used for any other purpose while data is being
                                 accessed. When we started to read from a DataReader it should always be open and positioned
                                 prior to the first record. The Read() method in the DataReader is used to read the rows from
                                 DataReader and it always moves forward to a new valid row, if any row exist.
                                 DataReader.Read();


        98                                LOVELY PROFESSIONAL UNIVERSITY
   99   100   101   102   103   104   105   106   107   108   109