Professor Corinne Hoisington
Professor Corinne Hoisington
NET
ADO.NET
Accessing Databases in VS.NET
Professor Corinne Hoisington
ADO.NET
ActiveX Data Objects
ADO.NET has a number of classes
that :
Retrieve Data
Manipulate Data
Update Data
VB,C#, C++, J#
ADO.NET
ADO vs. ADO.NET
ADO works great, but:
Requires COM and Windows
Recordsets dont travel well over the Internet
Connected behavior is hard to work with
Requires more code
ADO.NET solves these problems
Uses XML under the covers for all data
transport
No special code needed to marshal across
the Internet
ADO.NET
Disconnected?
ADO.NET offers the
capability of working with
databases in a disconnected
manner.
An entire database table can
be retrieved to a local
computer/temp file if it is a
network database.
A connection could also be
constant
ADO.NET
Web-Centric Applications
Download the data and
process it at a local
level.
If changes are made, the
connection can be
remade and the changes
posted.
The database could be
LAN or Internet based.
ADO.NET
Data Providers
MS SQL Server 7.0+
Oracle
OLE DB (old SQL & Access- Jet 4.0)
Open Database Connectivity
(ODBC)- earlier Visual Studio,
Access Driver, ODBC for Oracle
* Version 1.0 does not include ODBC
ADO.NET
4 Core Classes of ADO.NET
Connection-Connect to database
Command-SQL statement to retrieve
data
DataReader-Sequential access to the
data source
DataAdapter-Populate a dataset
& Update the database
ADO.NET
Other ADO Terms
Fill : The OleDbDataAdapter method Fill
retrieves information from the database
associated with OleDbConnection and
places this information in the DataSet.
DataGrid: A DataGrid is the area which
will be filled with data from the
database. The DataGrid method
SetDataBinding binds a DataGrid to a
data source.
ADO.NET
Architecture
ADO.NET
Choices?
Using ADO.NET
we can either
display
information in a:
DataGrid
Individual
Controls
ADO.NET
Lets Connect to a Database
ADO.NET
Adding a Connection
The ADD CONNECTION option is built
into ADO.NET to create a database
connection in the DATA LINK
PROPERTIES window. The DATA
ADAPTER CONFIGURATION WIZARD is
used to set up an OleDbDataAdapter
which generates queries to the
connected database.
ADO.NET
Connecting to the Database
Dragging an OleDbDataAdapter
from the Toolbox to the form of
displays the Data Adapter
Configuration Wizard.
Clicking Next on the welcome
screen displays the Choose
Your Data Connection window.
Clicking the New Connection
button pops up the Data Link
Properties form. Click the
Provider tab, choose Microsoft
Jet 4.0 OLE DB Provider
ADO.NET
SQL Commands:Creating a Query
ADO.NET
Time to try it!
ADO.NET
Using a Data Form Wizard
ADO.NET
Choosing Tables
ADO.NET
Fill the Form
ADO.NET
Lets Create Fill in Controls