Está en la página 1de 1

Accessing Data using System.Data The System.Data namespace provides access to classes that represent the ADO.NET architecture.

ADO.NET lets you build components that efficiently manage data from multiple data sources. In a disconnected scenario such as the Internet, ADO.NET provides the tools to request, update, and reconcile data in multiple tier systems. The ADO.NET architecture is also implemented in client applications, such as Windows Forms, or HTML pages created by ASP.NET. The centerpiece of the ADO.NET architecture is the DataSet class. A DataSet represents an in-memory cache of data.Each DataSet can contain multiple DataTable objects, with each DataTable containing data from a single data source, such as SQL Server. A DataTable represents one table of inmemory data. Using the System.Data.SqlClient namespace (the.NET Framework Data Provider for SQL Server), the System.Data.Odbc namespace (the.NET Framework Data Provider for ODBC), the System.Data.OleDb namespace (the.NET Framework Data Provider for OLE DB), or the System.Data.OracleClient namespace (the .NET Framework Data Provider for Oracle), you can access a data source to use together with a DataSet. Each.NET Framework data provider has a corresponding DataAdapter that you use as a bridge between a data source and a DataSet. The GridView allows for a number of different types of columns, :

The <SeparatorTemplate> element can be used to describe a separator between each record. Microsoft Data Report Designer The Microsoft Data Report designer is a versatile data report generator that features the ability to created banded hierarchical reports. Used in conjunction with a data source such as the Data Environment designer, you can create reports from several different relational tables. In addition to creating printable reports, you can also export the report to HTML or text files. Possible Uses

Automatically create reports that are exported in HTML format for instant distribution on the Internet. Create reports that show the sums of transactions occurring on a daily basis.

Data Report Designer Features The Data Report designer has several features: 1. Drag-and-Drop Functionality for FieldsDrag fields from the Microsoft Data Environment designer to the Data Report designer. When you do this, Visual Basic automatically creates a text box control on the data report and sets the DataMember and DataField properties of the dropped field. You can also drag a Command object from the Data Environment designer to the Data Report designer. In that case, for each of the fields contained by the Command object, a text box control will be created on the data report; the DataMember and DataField property for each text box will be set to the appropriate values. Toolbox ControlsThe Data Report designer features its own set of controls. When a Data Report designer is added to a project, the controls are automatically created on a new Toolbox tab named DataReport. Most of the controls are functionally identical to Visual Basic intrinsic controls, and include a Label, Shape, Image, TextBox, and Line control. The sixth control, the Function control, automatically generates one of four kinds of information: Sum, Average, Minimum, or Maximum. For more information about the Function control, see "Adding a Function Control to the Data Report." Print PreviewPreview the report by using the Show method. The data report is then generated and displayed in its own window. Note A printer must be installed on the computer to show the report in print preview mode. 4. Print ReportsPrint a report programmatically by calling the PrintReport method. When the data report is in preview mode, users can also print by clicking the printer icon on the toolbar. Note A printer must be installed on the computer to print a report. 5. File ExportExport the data report information using the ExportReport method. Formats for export include HTML and text. Export TemplatesYou can create a collection of file templates to be used with the ExportReport method. This is useful for exporting reports in a variety of formats, each tailored to the report type. Asynchonous OperationThe DataReport object's PrintReport and ExportReport methods are asynchronous operations. Using the ProcessingTimeout event, you can monitor the state of these operations and cancel any that are taking too long.

The BoundField, which displays the value of specified DataSource field as text. (This is the type of column used by default when tying a GridView to a DataSourcethrough the Smart Tag interface.) The ImageField, which displays an image based on an image path in a specified DataSource field. (We saw an example of using this column type in the previous exercise.)


Another useful column type is the TemplateField, which allows for a mix of HTML markup, Web controls, and data-binding syntax. One common use of a TemplateField is to perform custom logic to massage the output; another common use is to embed other Web controls within a GridView column. Repeater The Repeater control is used to display a repeated list of items that are bound to the control. The Repeater control may be bound to a database table, an XML file, or another list of items. The contents of the <HeaderTemplate> element are rendered first and only once within the output, then the contents of the <ItemTemplate> element are repeated for each "record" in the DataSet, and last, the contents of the <FooterTemplate> element are rendered once within the output: <asp:Repeater id="cdcatalog" runat="server"> <HeaderTemplate> ... </HeaderTemplate> <ItemTemplate> ... </ItemTemplate> <FooterTemplate> ... </FooterTemplate> </asp:Repeater> 7. <AlternatingItemTemplate> You can add an <AlternatingItemTemplate> element after the <ItemTemplate> element to describe the appearance of alternating rows of output. <SeparatorTemplate>