As an Access database developer, you will probably
ADO.NET is, loosely speaking, an extension of the ADO technology introduced slightly before Access 2000. Since ADO is actually a new data model relative to the earlier Remote Data Objects (RDO) and DAO technologies, you may be wondering why we need yet another set of objects for accessing and manipulating data.
There are a couple of
If you previously made the move from DAO to ADO, you will have a running start on learning ADO.NET. ADO was a strategic database technology because it
Another important reason for using ADO.NET is that it is smart about XML. You can readily persist ADO.NET data as XML documents and later read the
In order to begin an ADO.NET application, you must pick an appropriate data provider for the data source with which you want to work. The .NET Framework
When you are connecting to an Access 2000 or Access 2002 database, you should use the OLE DB .NET Data Provider. As the data provider s
COM was the development technology for exposing functionality and hosting applications. The .NET Framework will eventually supplant COM. In the interim, it will be necessary to run COM applications, such as the OLE DB Data Provider, with .NET applications. The COM Interop assembly facilitates this objective by mapping COM object members to equivalent
Since SQL Server is Microsoft s enterprise database, the .NET Framework ships with the SQL Server .NET Data Provider that is
The ODBC .NET Data Provider is the third .NET data provider. After the download, the data provider becomes an add-on component to the .NET Framework SDK. Your applications can use this data provider with any ODBC data source. Microsoft Knowledge Base article Q310985 provides insight on the use of this data provider, including sample code demonstrating its use with Visual Basic .NET.
There are two main elements to the ADO.NET architecture. First, the .NET data provider implements classes for connecting to and querying a database. Second, the .NET data providers transfer data to and from a database and a local
object. The users of your ADO.NET application will typically interact with the local dataset object. When appropriate, your application can
The four classes that a .NET data provider implements are the
The name of the
class implemented by the OLE DB .NET Data Provider is
. This class resides in the
namespace. In fact, all the classes implemented by the OLE DB .NET Data Provider reside in this namespace. To
Dim cnn1 As System.Data.OleDb.OleDbConnection = New _ System.Data.OleDb.OleDbConnection _ ("Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\myDB.mdb;") cnn1.Open()
If you program ADO, you will notice the striking similarity to ADO syntax. In spite of garbage collection, you should close the connection object as soon as you no longer need it. Invoke the object s Close or Dispose method to achieve this result.
After you create a connection to a database, you can execute commands against the database to perform data access, data manipulation, and data definition tasks. The name of the Command class implemented by the OLE DB .NET Data Provider is OleDbCommand . It resides in the same namespace as the OleDbConnection class. Use parameters to permit run-time specification of how a command operates. Command objects can pass data to other objects, such as DataReaders and DataAdapters.
The OLE DB .NET Data Provider implements the
object with the
class in the
namespace. Instances of this class provide read-only, forward-only access to a data source specified by a
object and a
object. When all you need to do is pass through some data, such as instructions to populate a list box, instances of the
class provide high performance. One reason for the high performance of
objects is that they maintain an open connection to a data source. You should close the
and its associated connection as soon as your application no longer needs them. This
The DataAdapter class acts as a bridge between an Access database or other external data source providing data to an ADO.NET application and a local DataSet object. Users of a form in a Windows application do not interact directly with the connected data source as is common with ADO applications coded with Visual Basic or VBA. Instead, the form in a Windows application points at the local DataSet object. This object is disconnected from the data source until a DataAdapte r object either fills the local dataset or updates the data source based on inserts, updates, and deletes to a local dataset. The name of the DataAdapter class from the OLE DB .NET Data Provider is OleDbDataAdapter; it resides in the System.Data.OleDb namespace.
class is in the
namespace. You can think of
objects as in-memory databases that contain one or more tables. When a dataset has more than one table, you can specify relationships between tables. You can also
The DataSet class is an exceptionally rich class that offers advantages for many data processing scenarios. Because a dataset can represent a whole database structure in memory, you can denote a data structure such as the Northwind database with multiple tables and many relationships. Within the DataSet class are collections for the tables and relationships in a dataset instance. Any individual table within a dataset can have a data row collection for representing values in the table and a data column collection for representing structure.
Perhaps the most important aspect of a dataset is that it is disconnected from its source. This feature increases the ability of the database source for a dataset to serve more users. That s because the ADO.NET architecture causes users to connect to a database only for a brief moment to either populate the dataset from the database source or to update the database source based on changes made to the dataset. Since Access databases tend to be bound by the number of concurrent users, this ADO.NET disconnected dataset feature can help to extend the life of Access databases that are currently experiencing performance degradation because of too many concurrent users.