X hits on this document

PDF document

“Beginning Visual C# 2005 Express Edition Video Series” - page 70 / 73





70 / 73


The .NET Framework allows us to work with all types of different databases, including Access, SQL Server 2005 Express Edition, Sql Server 2000, Sql Server 2005, Oracle and others through the user of a special set of .NET Framework classes called ADO.NET. ADO.NET provides two ways to work with data in a database.

Connected Database Access - In this first strategy, a connection to the database is opened and all the database operations such as selecting records, modifying records, deleting records, etc. is performed. Once you are finished making your changes, you can close the connection to the database.

Disconnected - In this strategy, a connection to the database is opened just long enough to get a set of records. Once the records are retrieved, the connection is closed. Then your code modifies the records, inserts new ones or deletes records and ADO.NET keeps track of all the changes. Then you command ADO.NET to connect back to the database and make those changes permanent by updating the actual database. The benefit of working with disconnected data is that you can free up system resources, such as database connections (in the case of SQL Server or Oracle) or reduce the amount of time the database is locked (when using Access).

In order to accomplish both of these approaches to data access, there are a series of classes in the System.Data namespace. I’ll overview them at a high level. For more information, use the Help system or view additional videos on LearnVisualStudio.NET.

Connection object – This object manages the “handshake” between your application and the external data source (database).

Command object – This object manages the request your application will make to retrieve or change data in the data source. Typically this will take the form of a SQL statement. It also manages any parameters that are sent to the data source in addition to the SQL statement. A command object must be associated with a connection, and then executed in order for it to perform its duty.

DataReader object – This object is used in a connected data scenario. Once the command object sends a request to retrieve

Supplemental Readings for the Express Edition Videos Copyright © 2005 LearnVisualStudio.NET


Document info
Document views113
Page views113
Page last viewedTue Oct 25 10:20:00 UTC 2016