【正文】
on and fast, forwardonly, readonly access to data. The Connection object provides connectivity to a data source. The Command object enables access to database mands to return data, modify data, run stored procedures, and send or retrieve parameter information. The DataReader provides a highperformance stream of data from the data source. Finally, the DataAdapter provides the bridge between the DataSet object and the data source. The DataAdapter uses Command objects to execute SQL mands at the data source to both load the DataSet with data, and reconcile changes made to the data in the DataSet back to the data source. You can write .NET Framework data providers for any data source. The .NET Framework ships with two .NET Framework data providers: the .NET Framework Data Provider for SQL Server and the .NET Framework Data Provider for OLE DB. The following diagram illustrates the ponents of architecture. Remoting or Marshaling Data between Tiers and Clients The design of the DataSet enables you to easily transport data to clients over the Web using XML Web services, as well as allowing you to marshal data between .NET ponents using .NET Remoting services. You can also remote a strongly typed DataSet in this fashion. .NET Framework Data Providers A .NET Framework data provider is used for connecting to a database, executing mands, and retrieving results. Those results are either processed directly, or placed in an DataSet in order to be exposed to the user in an adhoc manner, bined with data from multiple sources, or remoted between tiers. The .NET Framework data provider is designed to be lightweight, creating a minimal layer between the data source and your code, increasing performance without sacrificing functionality. The .NET Framework includes the .NET Framework Data Provider for SQL Server (for Microsoft SQL Server version or later), the .NET Framework Data Provider for OLE DB, and the .NET Framework Data Provider for ODBC. Connecting to SQL Server Using The .NET Framework Data Provider for SQL Server provides connectivity to Microsoft SQL Server version or later using the SqlConnection object. The .NET Framework Data Provider for SQL Server supports a connection string format that is similar to the OLE DB (ADO) connection string format. For valid string format names and values, see the Property. Closing the Connection It is remended that you always close the Connection when you are finished using it, in order for the connection to be returned to the pool. This can be done using either the Close or Dispose methods of the Connection object. Connections that are not explicitly closed might not be added or returned to the pool. For example, a connection that has gone out of scope but that has not been explicitly closed will only be returned to the connection pool if the maximum pool size has been reached and the connection is still valid. Note Do not call Close or Dispose on a Connection, a DataReader, or any other managed object in the Finalize method of your class. In a finalizer, only release unmanaged resources that your class owns directly. If your class does not own any unmanaged resources, do not include a Finalize method in your class definition. Integrated Security and SQL Server Integrated Security (also known as Trusted Connections) helps to provide protection when connecting to SQL Server as it does not expose a userid and password in the connection string and is the remended method for authenticating a connection. Integrated Security uses the current security identity, or token, of the executing process. For desktop applications, this is, most monly, the identity of the currently logged on user. The security identity for applications can be set to one of several different options. Performing Database Operations and Modifying Data Using a .NET Framework data provider, you can execute stored procedures or data definition language (DDL) statements (for example, CREATE TABLE and ALTER COLUMN) to perform schema manipulation on a database or catalog. These mands do not return rows as a query would, so the Command object provides an ExecuteNonQuery method to process them. In addition to using ExecuteNonQuery to modify schema, you can also use this method to process SQL statements that modify data but that do not return rows, such as INSERT, UPDATE, and DELETE. Although rows are not returned by the ExecuteNonQuery method, input and output parameters and return values can be passed and returned via the Parameters collection of the Command object. Introduction to is more than the next version of Active Server Pages (ASP)。 controls) possible, but with significant improvements that only managed code can offer, such as semitrusted execution and isolated file storage. The following illustration shows the relationship of the mon language runtime and the class library to your applications and to the overall system. The illustration also shows how managed code operates within a larger architecture. Features of the Common Language Runtime The mon language runtime manages memory, thread execution, code execution, code safety verification, pilation, and other system services. These features are intrinsic to the managed code that runs on the mon language runtime. With regards to security, managed ponents are awarded varying degrees of trust, depending on a number of factors that include their origin (such as the Inter, enterprise work, or local puter). This means that a managed ponent might or might not be able to perform fileaccess operations, registryaccess operations, or other sensitive functions, even if it is being used in the same active application. The runtime enforces code access security. For example, users can trust that an executable embedded in a Web page can play an animat