Guidelines for choosing a NET data provider

How To Reference a .NET Data Provider Choosing the appropriate .NET data provider for your application depends on the type of data source that is being accessed. Use the Visual Studio .NET Solution Explorer to manage references to assemblies that implement .NET data providers. The System.Data.dll assembly (physically a single DLL file) implements the SQL Server .NET Data Provider and the OLE DB .NET Data Provider in the System.Data.SqlClient and System.Data.OleDb namespaces. The...

ADO and Ado Net Comparison

This appendix provides Web links to additional resources about Microsoft .NET, Microsoft ActiveX Data Objects (ADO) .NET, and related technologies. These Web links are subject to change. The following resources provide information about ADO.NET and Microsoft SQL Server Accessing Data with ADO.NET Introducing ADO+ Data Access Services for the Microsoft .NET Framework ADO.NET for the ADO Programmer ADO to XML Building a Data Access Tier with the DataManager Component SQL and XML Use XML to Invoke...

Monitoring and Managing Connection Pooling with SQL Server

Because applications often require multiple connections with multiple users, connecting to a data source can be resource-intensive. By pooling connections, you can keep connections available for reuse, which will enhance application performance and scalability. The number of employees at Northwind Traders is rapidly growing, and as a result more applications are connecting to data sources. The company needs to optimize server resources by pooling connections. In this exercise, you will monitor...

Extract a subset of information from a Data Set

*****************************illegal for non-trainer use****************************** Why perform XPath queries on a DataSet Additional objects needed to perform XPath queries You can use an XPath query to extract certain parts of an XML file or navigate the nodes in the DOM representation of the XML data. If the data that you want to query is stored in a DataSet, you could create a new XML file by using the WriteXml method of the DataSet object. However, you can eliminate this step by...

The Data Set Object Model

Tables (collection of DataTable objects) Relations (collection of DataRelation objects) Relations between tables in a DataSet The DataSet class has a Tables property, which gets a collection of DataTable objects in the DataSet, and a Relations property, which gets a collection of the DataRelation objects in the DataSet. A DataTable object contains several collections that describe the data in the table and to cache the data in memory. The following table describes the most important...

Syntax of the Update method

Public abstract int Update( Dataset dataset The Update method of a DataAdapter object calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified DataSet from a DataTable named Table. The Update method of a DataAdapter object is distinct and different from the UpdateCommand property of a DataAdapter object, which gets or sets a SQL statement or OleDBbCommand that updates records in the data source. The C syntax for the Update method of...

How to Create a Data Set a Data Table and a Data Column

MyDataSet New Dim workTable As New DataTable (Customers) Creating a DataColumn and adding it to a DataTable Dim workCol As DataColumn workTable.Columns.Add( _ CustID, GetType (System.Int32) *****************************illegal for non-trainer use****************************** Introduction You can create DataSets and DataTables in the following ways By using the graphical tools in the Microsoft Visual Studio .NET development environment By using a DataAdapter and filling the DataSet with data...

You must specify

A new or existing connection How to create a data adapter using the Data Adapter Configuration Wizard You can create a data adapter to execute an existing stored procedure. This enables disconnected applications to retrieve complex table joins, by using existing functionality in the database. You can create the data adapter by using the Data Adapter Configuration Wizard, or programmatically in your code. You must specify a connection to the required database. You must also specify the name of...

Reviewing the Application

In this exercise, you will review a complete solution to this lab so that you clearly understand how it works. This solution will show how the application loads data into the disconnected application. Then you will review a starter solution that will be the starting point for the application you will complete in the other exercises of Labs 6.1 and 6.2. Scenario The On The Road Windows application is used by Northwind Traders sales people to track customer orders while the user is on the road,...

How to handle multiple types of exceptions

Write the code to execute inside a Try block Write a Catch statement for each specific exception that you want to catch Write a generic Catch statement for all other exceptions Write a Finally statement to run the code no matter what happens End the exception handler with an End Try block ILLEGAL FOR NONTRAINER USE When you write an exception handler that uses a Try Catch Finally block, you can use as many Catch blocks as you feel are necessary. Write a Finally block to run the code...

Review

What are the characteristics of a connected architecture What are the characteristics of a disconnected architecture What are the features and advantages of a distributed public XML Web Service architecture How does ADO .NET increase the interoperability and scalability of disconnected systems What is a dataset, and why is it important in ADO .NET Which .NET data providers are included in the .NET Framework illegal for non-trainer use illegal for non-trainer use 1. What are the characteristics...

IsDbNull method

Guidelines for iterating through a result set Guidelines for getting column values SqlDataReader and OleDbDataReader contain properties and methods for processing a result set retrieved by a command object. These properties and methods enable you to Iterate through the result set, one row at a time. Get the value of a specific column, or all columns, in the current row. Check whether a column contains a missing or non-existent value. Get metadata for a column, such as its name, ordinal...

Call Fill Schema to build a new Data Set schema

DataAdapter executes SelectCommand, to determine the structure of the data You can fill a DataSet even if the schema is not known at design time. The DataSet schema can be created at runtime, based on the structure of the retrieved data. You can control how a DataSet schema is created and modified at runtime. Before you fill the dataset, do one of the following Set the MissingSchemaAction property on the DataAdapter Call the FillSchema method on the DataAdapter Set the MissingSchemaAction...

How to Fill a Data Set with an ADO Recordset or Record

How to consume a COM component that returns an ADO Recordset or Record Using the Visual Studio .NET development environment To provide access to ADO Recordset and Record objects from ADO.NET, the OLE DB .NET Data Provider overloads the Fill method of the OleDbDataAdapter class to accept an ADO Recordset or Record object. Filling a DataSet with the contents of an ADO object is a one-way operation. That is, data can be imported from the ADO Recordset or Record object into the DataSet, but any...

Loading XML Data into a Data Set Simplified syntax

Dataset.ReadXML Stream FileName TextReader XMLReader, ByVal mode as XMLReadMode Visual Basic Example Visual Basic Example Visual Basic Example illegal for non-trainer use Loading data and schema by using the Dataset.ReadXML method You can use the ReadXml method of the DataSet object to load data from an XML file into a DataSet. When you use this method, you can load data from XML files that contain only XML data, or from files that contain XML data as well as an inline schema. An inline schema...

How to Create a Data Adapter that Uses a New Select Statement

You can create a data adapter to execute a new SELECT statement Read-only data access for disconnected applications Two ways to create the data adapter Use the Data Adapter Configuration Wizard Write the code yourself You must specify A new or existing connection The SELECT statement for the query How to create a data adapter by using the Data Adapter Configuration Wizard You can create a DataAdapter object to execute a new SELECT statement. This provides disconnected applications with...

Editing Rows in a Data Table

In this exercise, you will provide a simple method to add new cart items to the shopping cart. To supply the basic values required for a cart item, you will open an existing DataSet file that contains sample categories and products. Scenario When browsing the Northwind Traders e-commerce Web site, a customer will want the ability to add an item to his or her shopping cart with a single click. To start with the solution to the previous exercise If you did not complete the previous exercise open...

Examples of controlling SQL Server connection pooling

illegal for non-trainer use You can control several elements of connection pooling when you connect to SQL Server by using the SQL Server .NET Data Provider. You can control how long the connection exists, whether the database connection is reset when the connection is removed from the pool, how many connections are allowed and maintained in the pool, and whether pooling is enabled. The following keywords are specified in the connection string in order to control connection pooling. When a...

Performing an XPATH query on a Data Set

The XmlDataDocument object allows you to load relational data or XML data, and process the data by using World Wide Web Consortium W3C Document Object Model DOM techniques. After completing this lesson, you will be able to Explain what an XmlDataDocument object is. Synchronize an XmlDataDocument with a DataSet. Diagram a hierarchical view of existing relational data. Provide a relational view of XML data. Apply an XSL T style sheet to a DataSet. Perform an XPath query on a DataSet.

How to Expose COM Components to the NET Framework

Introduction This section summarizes the process for exposing an existing COM component, Existing COM components are valuable resources in managed code as middle-tier business applications or as an isolated functionality. An ideal component has a primary Interop assembly and closely conforms to the programming standards imposed by COM. How to expose COM To expose a COM component to the .NET Framework, perform the following 1. Import a type library as an assembly. The common language runtime...

Testing the Row Version by calling the Has Version method and passing a Data RowVersion as an argument

The DataRow class includes the RowState property, whose values indicate whether and how the row has changed since the DataTable was first created or loaded from the database. RowState property values include Deleted, Modified, New, and Unchanged. Changes made to column values in a DataRow are immediately placed in the Current state of the row. At this point the RowState is set to Modified. When modifying column values in a DataRow directly, the DataRow manages column values by using the...