KEMBAR78
Is2215 lecture7 lecturer_ado_intro | PPTX
DATABASES IN VISUAL BASIC.NET

ADO.NET
ADO .NET


  ADO.NET is an OO framework that allows
   you to interact with DBs
  Can use ADO.NET through code, or by using
   bounded controls
  ADO.NET extremely flexible and efficient
ADO.NET

   Previously applications would talk to Database
      using SQL
     The application would be constantly connected
      to the DB
     We still use SQL but the data is disconnected
     It will connect to a database server when it
      needs to run a query and then disconnects
      immediately
     ADO.NET still provides the connection
      oriented traditional approach.
Traditional Data Access
Architecture

1. Makes a Connection
2. Pass some query to DB and reads result
3. Pass another query to DB and reads result
4. Disconnects from DB System
ADO.NET Disconnected Model

1. Make a connection
2. Pass query and gets back result
3. Disconnects
4. Makes connection again
5. Passes another query and gets result
6. Disconnects from the DB
ADO.NET

 Keeps a local virtual copy of the database in
  your application
 All of the generic classes for data access are
  stored in the System.Data Namespace.
ADO.NET

   ADO.NET uses managed providers to
    connect to databases
   Managed providers allow fast data streams
    from databases
   Deals with security such as database locks,
    passwords etc.,
Main Components of ADO.NET

Object          Description

Connection      Creates a connection to the data
                source
Command         Provides access to commands
                that can be executed against the
                data source
DataAdapter     Serves as an ambassador
                between your dataset and
                datasource, maps instructions
                between the two
DataSet         Provides an in-memory
                representation of your data source
DataReader      Read-Only forward stream
                containing your data
Advantages

 Interoperability
   Data is transported as XML
   Can be read by anyone on any platform
 Scalability
   Client Server model is gone
   ADO promotes the use of disconnected datasets
 Productivity
   Quicker
   Less Bugs
Advantages Cont’d

 Performance
   Disconnected datasets
   Database Server is no longer a bottleneck
   Performance boost
   Concurrency
   Database not locked out all the time
Using ADO.NET in Code

1. Set up your objects
2. Connect to DB using connection object
3. Set up the data adapter
4. Copy data from data adapter to Dataset
Connecting to a DB in Code
USING ADO.NET WITH ACCESS DB
A Simple DB Application
Code Cont’d
Code Cont’d
Code Cont’d
Doing it In Code

 An access Database Table
 It will be represented in our DataSet as a Table
 The first table is given an index of 0
 The first row in the table has an index value of 0
  also
 The first column has a value of 0
Code Cont’d
The Code

Set up the objects
The Code

Set up the objects
The Code

Set up the objects
The Code

Set up the objects
The Code

Set up the objects
The Code

Fill the DataSet using the DataAdapter
The Code – Displaying the
      DataSet Contents
 Point a textbox to a row and column of the dataset
  Table
 Point a DataGrid control at a DataSet




    .........................................................................................................
    .
The Code: Counting the
Number of Rows
 Point a textbox to a row and column of the dataset
  Table
 Point a DataGrid control at a DataSet




    .........................................................................................................
    .
Customising the Generic
Code
Set Up the Objects
The Form Load Code
The UpdateTextBoxes Sub
Procedure
Navigation Code: Previous
Record
Navigation Code: Next Record
Navigation Code: Find Record

Is2215 lecture7 lecturer_ado_intro

  • 1.
    DATABASES IN VISUALBASIC.NET ADO.NET
  • 2.
    ADO .NET ADO.NET is an OO framework that allows you to interact with DBs  Can use ADO.NET through code, or by using bounded controls  ADO.NET extremely flexible and efficient
  • 3.
    ADO.NET Previously applications would talk to Database using SQL  The application would be constantly connected to the DB  We still use SQL but the data is disconnected  It will connect to a database server when it needs to run a query and then disconnects immediately  ADO.NET still provides the connection oriented traditional approach.
  • 4.
    Traditional Data Access Architecture 1.Makes a Connection 2. Pass some query to DB and reads result 3. Pass another query to DB and reads result 4. Disconnects from DB System
  • 5.
    ADO.NET Disconnected Model 1.Make a connection 2. Pass query and gets back result 3. Disconnects 4. Makes connection again 5. Passes another query and gets result 6. Disconnects from the DB
  • 6.
    ADO.NET  Keeps alocal virtual copy of the database in your application  All of the generic classes for data access are stored in the System.Data Namespace.
  • 7.
    ADO.NET  ADO.NET uses managed providers to connect to databases  Managed providers allow fast data streams from databases  Deals with security such as database locks, passwords etc.,
  • 8.
    Main Components ofADO.NET Object Description Connection Creates a connection to the data source Command Provides access to commands that can be executed against the data source DataAdapter Serves as an ambassador between your dataset and datasource, maps instructions between the two DataSet Provides an in-memory representation of your data source DataReader Read-Only forward stream containing your data
  • 9.
    Advantages  Interoperability  Data is transported as XML  Can be read by anyone on any platform  Scalability  Client Server model is gone  ADO promotes the use of disconnected datasets  Productivity  Quicker  Less Bugs
  • 10.
    Advantages Cont’d  Performance  Disconnected datasets  Database Server is no longer a bottleneck  Performance boost  Concurrency  Database not locked out all the time
  • 11.
    Using ADO.NET inCode 1. Set up your objects 2. Connect to DB using connection object 3. Set up the data adapter 4. Copy data from data adapter to Dataset
  • 13.
    Connecting to aDB in Code USING ADO.NET WITH ACCESS DB
  • 14.
    A Simple DBApplication
  • 15.
  • 16.
  • 17.
  • 18.
    Doing it InCode  An access Database Table  It will be represented in our DataSet as a Table  The first table is given an index of 0  The first row in the table has an index value of 0 also  The first column has a value of 0
  • 20.
  • 21.
    The Code Set upthe objects
  • 23.
    The Code Set upthe objects
  • 25.
    The Code Set upthe objects
  • 27.
    The Code Set upthe objects
  • 29.
    The Code Set upthe objects
  • 31.
    The Code Fill theDataSet using the DataAdapter
  • 32.
    The Code –Displaying the DataSet Contents  Point a textbox to a row and column of the dataset Table  Point a DataGrid control at a DataSet ......................................................................................................... .
  • 33.
    The Code: Countingthe Number of Rows
  • 34.
     Point atextbox to a row and column of the dataset Table  Point a DataGrid control at a DataSet ......................................................................................................... .
  • 35.
  • 36.
    Set Up theObjects
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.