ADO.NET

26
Microsoft® ADO.NET Presented by Joseph J. Sarna Jr. JJS Systems, LLC

description

ADO.NET

Transcript of ADO.NET

  • Microsoft ADO.NETPresented byJoseph J. Sarna Jr.JJS Systems, LLC

  • AgendaADO versus ADO.NETADO.NET ArchitectureConnection ObjectCommand ObjectDataReader ObjectDataAdapter ObjectDataSet ObjectDataView ObjectUse ADO.NET to access data in an application

  • ADO versus ADO.NET

    FeatureADOADO.NETPrimary AimClient/server coupled Disconnected collection of data from data serverForm of data in memoryUses RECORDSET object (contains one table)Uses DATASET object (contains one or more DATATABLE objects)Disconnected accessUses CONNECTION object and RECORDSET object with OLEDBUses DATASETCOMMAND object with OLEDBDisconnected access across multi-tiersUses COM to marshal RECORDSET Transfers DATASET object via XML. No data conversions required

  • ADO versus ADO.NET (continued)

    FeatureADOADO.NETXML capabilitiesXML awareXML is the native transfer medium for the objectsFirewallsFirewalls block system-level COM marshallingXML flows through the firewall via HTTPCodeCoupled to the language used, various implementationManaged code library Uses Common Language Runtime, therefore, language agnostic

  • AgendaADO versus ADO.NETADO.NET ArchitectureConnection ObjectCommand ObjectDataReader ObjectDataAdapter ObjectDataSet ObjectDataView ObjectUse ADO.NET to access data in an application

  • ADO.NET Architecture Diagram

  • ADO.NET Namespaces

    System.data Core namespace, defines types that represent dataSystem.Data.CommonTypes shared between managed providersSystem.Data.OleDbTypes that allow connection to OLE DB compliant data sourcesSystem.Data.SqlClientTypes that are optimized to connect to Microsoft SQL ServerSystem.Data.SqlTypesNative data types in Microsoft SQL Server

  • Importing the ADO.NET NamespacesNeeded to build a data access application

    For OLE DB:Imports System.DataImports System.Data.OleDB

    For SQL Server:Imports System.DataImports System.Data.SQLClient

  • AgendaADO versus ADO.NETADO.NET ArchitectureConnection ObjectCommand ObjectDataReader ObjectDataAdapter ObjectDataSet ObjectDataView ObjectUse ADO.NET to access data in an application

  • Connection objectConnects to databases. Two provider-specific classes SqlConnection OleDbConnection. Connections can be opened in two ways:Explicitly by calling the Open method on the connectionImplicitly when using a DataAdapter. Connections handle transactions

  • AgendaADO versus ADO.NETADO.NET ArchitectureConnection ObjectCommand ObjectDataReader ObjectDataAdapter ObjectDataSet ObjectDataView ObjectUse ADO.NET to access data in an application

  • Command ObjectInformation submitted to a database as a query via a Connection objectTwo provider-specific classesSqlCommandOleDbCommandInput and output parameters are supported, along with return values as part of the command syntaxResults are returned in the form of streams. Accessed by:DataReader objectDataSet object via a DataAdapter

  • AgendaADO versus ADO.NETADO.NET ArchitectureConnection ObjectCommand ObjectDataReader ObjectDataAdapter ObjectDataSet ObjectDataView ObjectUse ADO.NET to access data in an application

  • DataReader ObjectProvides methods and properties that deliver a forward-only stream of data rows from a data sourceWhen a DataReader is used, parts of the ADO.NET model are cut out, providing faster and more efficient data access

  • Create DataReader Example

  • AgendaADO versus ADO.NETADO.NET ArchitectureConnection ObjectCommand ObjectDataReader ObjectDataAdapter ObjectDataSet ObjectDataView ObjectUse ADO.NET to access data in an application

  • DataAdapter ObjectProvides a set of methods and properties to retrieve and save data between a DataSet and its source data storeAllows the use of stored proceduresConnects to the database to fill the DataSet and also update the database

  • AgendaADO versus ADO.NETADO.NET ArchitectureConnection ObjectCommand ObjectDataReader ObjectDataAdapter ObjectDataSet ObjectDataView ObjectUse ADO.NET to access data in an application

  • DataSet ObjectReplaces the ADO RecordsetRepresents a cache of data that contains tables, columns, relationships, and constraints, just like a databaseRegardless of where the source data comes from, data can all be placed into DataSet objectsTracks changes that are made to the data it holds before updating the source dataDataSet are also fully XML-featuredWorks with all current models of data storage: flat, relational, and hierarchical

  • AgendaADO versus ADO.NETADO.NET ArchitectureConnection ObjectCommand ObjectDataReader ObjectDataAdapter ObjectDataSet ObjectDataView ObjectUse ADO.NET to access data in an application

  • DataView ObjectProvides methods and properties that enable UI objects such as a DataGrid to bind to a DataSet A view of the data contained in the DataSetOnly used in conjunction with a DataSet

  • AgendaADO versus ADO.NETADO.NET ArchitectureConnection ObjectCommand ObjectDataReader ObjectDataAdapter ObjectDataSet ObjectDataView ObjectUse ADO.NET to access data in an application

  • Create Data Access Windows Form

  • Create Multiple Table DataSet Example

  • SummaryADO versus ADO.NETADO.NET ArchitectureConnection ObjectCommand ObjectDataReader ObjectDataAdapter ObjectDataSet ObjectDataView ObjectUse ADO.NET to access data in an application

  • New Hampshire Access/Visual Basic User GroupMeets 4th Wednesday of each month

    Meetings held at Southern New Hampshire University

    Link to Information - http://www.jjssystems.net

    *