Ado dot net database connectivity

download Ado dot net database connectivity

of 19

Transcript of Ado dot net database connectivity

  • 7/27/2019 Ado dot net database connectivity

    1/19

    ADO.NET

    ADO.NET

    Accessing Databases in VS.NETProfessor Corinne Hoisington

  • 7/27/2019 Ado dot net database connectivity

    2/19

    ADO.NET

    ActiveX Data Objects

    ADO.NET has a number of classes

    that :

    Retrieve Data

    Manipulate Data

    Update Data

    VB,C#, C++, J#

  • 7/27/2019 Ado dot net database connectivity

    3/19

    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 datatransport

    No special code needed to marshal acrossthe Internet

  • 7/27/2019 Ado dot net database connectivity

    4/19

    ADO.NET

    Disconnected?

    ADO.NET offers thecapability of working withdatabases in a disconnectedmanner.

    An entire database table canbe retrieved to a localcomputer/temp file if it is anetwork database.

    A connection could also beconstant

  • 7/27/2019 Ado dot net database connectivity

    5/19

    ADO.NET

    Web-Centric Applications

    Download the data andprocess it at a locallevel.

    If changes are made, theconnection can beremade and the changesposted.

    The database could beLAN or Internet based.

  • 7/27/2019 Ado dot net database connectivity

    6/19

    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

  • 7/27/2019 Ado dot net database connectivity

    7/19

    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

  • 7/27/2019 Ado dot net database connectivity

    8/19

    ADO.NET

    Other ADO Terms

    Fill : The OleDbDataAdapter method Fillretrieves information from the databaseassociated with OleDbConnection and

    places this information in the DataSet. DataGrid: A DataGridis the area which

    will be filled with data from thedatabase. The DataGrid method

    SetDataBinding binds a DataGrid to adata source.

  • 7/27/2019 Ado dot net database connectivity

    9/19

    ADO.NET

    Architecture

  • 7/27/2019 Ado dot net database connectivity

    10/19

    ADO.NET

    Choices?

    Using ADO.NET

    we can either

    displayinformation in a:

    DataGrid

    Individual

    Controls

  • 7/27/2019 Ado dot net database connectivity

    11/19

    ADO.NET

    Lets Connect to a Database

  • 7/27/2019 Ado dot net database connectivity

    12/19

    ADO.NET

    Adding a Connection

    TheADD CONNECTIONoption is builtinto ADO.NET to create a database

    connection in theDATA LINK

    PROPERTIESwindow. The DATAADAPTER CONFIGURATION WIZARD isused to set up an OleDbDataAdapterwhich generates queries to theconnected database.

  • 7/27/2019 Ado dot net database connectivity

    13/19

    ADO.NET

    Connecting to the Database

    Dragging an OleDbDataAdapterfrom the Toolbox to the form ofdisplays the Data AdapterConfiguration Wizard.

    Clicking Next on the welcomescreen displays the ChooseYour Data Connection window.

    Clicking the New Connectionbutton pops up the Data LinkProperties form. Click theProvider tab, choose MicrosoftJet 4.0 OLE DB Provider

  • 7/27/2019 Ado dot net database connectivity

    14/19

    ADO.NET

    SQL Commands:Creating a Query

  • 7/27/2019 Ado dot net database connectivity

    15/19

    ADO.NET

    Time to try it!

    http://localhost/var/www/apps/conversion/tmp/scratch_4/ADOExample.doc
  • 7/27/2019 Ado dot net database connectivity

    16/19

    ADO.NET

    Using a Data Form Wizard

  • 7/27/2019 Ado dot net database connectivity

    17/19

    ADO.NET

    Choosing Tables

  • 7/27/2019 Ado dot net database connectivity

    18/19

    ADO.NET

    Fill the Form

  • 7/27/2019 Ado dot net database connectivity

    19/19

    ADO.NET

    Lets Create Fill in Controls

    http://localhost/var/www/apps/conversion/tmp/scratch_4/VB%20Form%20Wizard.doc