You are on page 1of 3

Week 5 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 e iciently manage data rom multiple data sources. !n a disconnected scenario such as the !nternet" ADO.NET provides the tools to re#uest" update" and reconcile data in multiple tier systems. The ADO.NET architecture is also implemented in client applications" such as Windo$s %orms" or &T'( pages created by AS).NET. The centerpiece o the ADO.NET architecture is the DataSet class. A DataSet represents an in*memory cache o data.Each DataSet can contain multiple DataTable ob+ects" $ith each DataTable containing data rom a single data source" such as S,( Server. A DataTable represents one table o in*memory data. -sing the System.Data.S#l.lient namespace /the.NET %rame$ork Data )rovider or S,( Server0" the System.Data.Odbc namespace /the.NET %rame$ork Data )rovider or OD1.0" the System.Data.OleDb namespace /the.NET %rame$ork Data )rovider or O(E D10" or the System.Data.Oracle.lient namespace /the .NET %rame$ork Data )rovider or Oracle0" you can access a data source to use together $ith a DataSet. Each.NET %rame$ork data provider has a corresponding DataAdapter that you use as a bridge bet$een a data source and a DataSet. The GridView allo$s or a number o di erent types o columns" 2 The BoundField" $hich displays the value o speci ied DataSource ield as te3t. /This is the type o column used by de ault $hen tying a GridView to a DataSourcethrough the Smart Tag inter ace.0 The ImageField" $hich displays an image based on an image path in a speci ied DataSource ield. /We sa$ an e3ample o using this column type in the previous e3ercise.0 Another use ul column type is the Template%ield" $hich allo$s or a mi3 o &T'( markup" Web controls" and data*binding synta3. One common use o a Template%ield is to per orm custom logic to massage the output4 another common use is to embed other Web controls $ithin a GridView column. Repeater The 5epeater control is used to display a repeated list o items that are bound to the control. The 5epeater control may be bound to a database table" an 6'( ile" or another list o items. The contents o the 7&eaderTemplate8 element are rendered irst and only once $ithin the output" then the contents o the 7!temTemplate8 element are repeated or each 9record9 in the DataSet" and last" the contents o the 7%ooterTemplate8 element are rendered once $ithin the output2 7asp25epeater id:9cdcatalog9 runat:9server98 7&eaderTemplate8 ... 7;&eaderTemplate8 7!temTemplate8 ... 7;!temTemplate8 7%ooterTemplate8 ... 7;%ooterTemplate8

7;asp25epeater8 7Alternating!temTemplate8 <ou can add an 7Alternating!temTemplate8 element a ter the 7!temTemplate8 element to describe the appearance o alternating ro$s o output. 7SeparatorTemplate8 The 7SeparatorTemplate8 element can be used to describe a separator bet$een each record. 'icroso t Data 5eport Designer The 'icroso t Data 5eport designer is a versatile data report generator that eatures the ability to created banded hierarchical reports. -sed in con+unction $ith a data source such as the Data Environment designer" you can create reports rom several di erent relational tables. !n addition to creating printable reports" you can also e3port the report to &T'( or te3t iles. )ossible -ses

Automatically create reports that are e3ported in &T'( ormat or instant distribution on the !nternet. .reate reports that sho$ the sums o transactions occurring on a daily basis.

Data 5eport Designer %eatures The Data 5eport designer has several eatures2 =. Drag-and-Drop Functionality for Fields>Drag ields rom the 'icroso t Data Environment designer to the Data 5eport designer. When you do this" ?isual 1asic automatically creates a te3t bo3 control on the data report and sets the Data'ember and Data%ield properties o the dropped ield. <ou can also drag a .ommand ob+ect rom the Data Environment designer to the Data 5eport designer. !n that case" or each o the ields contained by the .ommand ob+ect" a te3t bo3 control $ill be created on the data report4 the Data'ember and Data%ield property or each te3t bo3 $ill be set to the appropriate values. @. Toolbo !ontrols>The Data 5eport designer eatures its o$n set o controls. When a Data 5eport designer is added to a pro+ect" the controls are automatically created on a ne$ Toolbo3 tab named Data5eport. 'ost o the controls are unctionally identical to ?isual 1asic intrinsic controls" and include a (abel" Shape" !mage" Te3t1o3" and (ine control. The si3th control" the %unction control" automatically generates one o our kinds o in ormation2 Sum" Average" 'inimum" or 'a3imum. %or more in ormation about the %unction control" see 9Adding a %unction .ontrol to the Data 5eport.9 A. "rint "re#iew>)revie$ the report by using the Sho$ method. The data report is then generated and displayed in its o$n $indo$. $ote A printer must be installed on the computer to sho$ the report in print previe$ mode. B. "rint Reports>)rint a report programmatically by calling the )rint5eport method. When the data report is in previe$ mode" users can also print by clicking the printer icon on the toolbar. $ote A printer must be installed on the computer to print a report. 5. File % port>E3port the data report in ormation using the E3port5eport method. %ormats or e3port include &T'( and te3t.

C. % port Templates><ou can create a collection o ile templates to be used $ith the E3port5eport method. This is use ul or e3porting reports in a variety o ormats" each tailored to the report type. D. Async&onous 'peration>The Data5eport ob+ectEs )rint5eport and E3port5eport methods are asynchronous operations. -sing the )rocessingTimeout event" you can monitor the state o these operations and cancel any that are taking too long.
F parent older;absolute directory 'ap)ath physical directory

You might also like