Datenbankprogrammierung von DAO nach ADO Tilo Böttcher, Technology Specialist Hans Brender, Presales Consultant tiloboet@microsoft.com Microsoft GmbH.

Slides:



Advertisements
Ähnliche Präsentationen
Cadastre for the 21st Century – The German Way
Advertisements

E-Solutions mySchoeller.com for Felix Schoeller Imaging
Transaction Synchronization for XML Data in Client Server Web Applications Stefan Böttcher & Adelhard Türling Universität Paderborn.
G21Billing Document Outbound via EDI Overview
G66 Empties Processing Overview
G20 Sales Order Processing via EDI Overview
Transportation Management Overview (G82)
Entwicklung und Einsatz von Smart Client-Anwendungen Jens Häupel Developer Evangelist Microsoft Deutschland GmbH Dirk Primbs.
Erstellung von Datenprojekten (*.adp)
Windows Vista Deployment
Windows Vista für Entwickler
Neue Mobilität Frank Prengel Developer Evangelist Developer Platform & Strategy Group Microsoft Deutschland GmbH
1. 2 Microsoft.NET Überblick Dirk Primbs Technologieberater Developer Platform & Strategy Group Microsoft Deutschland GmbH.
Herzlich Willkommen zum Informations-Forum: SAP Interoperabilität
Installation des Add-In SOLVERSTAT
PL/SQL - Programmierung von Programmeinheiten. © Prof. T. Kudraß, HTWK Leipzig Gespeicherte Prozeduren – Eine Prozedur ist ein benannter PL/SQL Block,
WebCast: Managed Smart Tags mit VSTO Jens Häupel.NET Technologieberater Microsoft Deutschland GmbH
Frank Fischer Manager Evangelism and Marketing Microsoft Deutschland GmbH.
Gehärtet von Anfang an { Windows 2008: Spezielle Aufgaben }
Microsoft Office Forms Server
Windows Essential Business Server 2008
Institut AIFB, Universität Karlsruhe (TH) Forschungsuniversität gegründet 1825 Towards Automatic Composition of Processes based on Semantic.
OO implementieren Teil IV Objekte erzeugen. © René ProbstModul 226IV - 2 Von der Klasse zum Objekt Plan Bau Objekt Klasse Instanzierung Objekt Das Objekt.
Martin LöfflerMurat Yilmaz Labor Informationstechnologie.
Sanjay Patil Standards Architect – SAP AG April 2008
| DC-IAP/SVC3 | © Bosch Rexroth Pneumatics GmbH This document, as well as the data, specifications and other information set forth in.
Vergleich der verschiedenen kommerziellen Datenbanksysteme
3rd Review, Vienna, 16th of April 1999 SIT-MOON ESPRIT Project Nr Siemens AG Österreich Robotiker Technische Universität Wien Politecnico di Milano.
Projekt Alcatraz Java RMI / Spread - Gruppe A4.
© All rights reserved. Zend Technologies, Inc. Jan Burkl System Engineer, Zend Technologies Zend Server im Cluster.
| Basel Von der SharePoint Taskliste zum gemanagten Project in Project Server Luca Argentiero Solution Specialist Microsoft
The free XML Editor for Windows COOKTOP Semistrukturierte Daten 1 Vortrag Semistrukturierte Daten 1 COOKTOP The free XML-Editor for Windows
ORMapper: NHibernate Henning Eiben
Advanced Mapping Persistente Domänenmodelle mit JPA 2.0 und Bean Validation.
Jan Hentschel Microsoft Expert Student Partner Windows Azure Windows Azure Windows Azure Mobile Services.
Neno Loje Berater & MVP für Visual Studio ALM und TFS (ehemals VSTS) Hochqualitative Produkte mit Visual Studio & TFS 2010.
Dariusz Parys Developer Evangelist Microsoft Deutschland GmbH.
Frank Fischer + Bernhard Frank Microsoft Deutschland GmbH.
Roger Boesch Developer Technical Specialist Developer and Platform Group.
Thomas Claudius Huber Senior Consultant Trivadis AG Silverlight 5 die Neuerungen.
Quelle: Standish Group, 2006 Fourth Quarter Research Report, CHAOS Research Results.
3/28/2017 8:11 PM Visual Studio Tools für Office { Rapid Application Development für Office } Jens Häupel Platform Strategy Manager Microsoft Deutschland.
Spricht Ihre Anwendung schon Open XML?
MVVM in Windows 8 und Windows Phone 8
PresenterCompanyContact Windows Azure ASP.NET Web-Anwendungen schnell und zuverlässig bereitstellen.
XML IV: Cocoon 2.
1 Softwareentwicklung mit.NET Teil 5 Datenzugriff mit ADO.NET Dr. Ralph Zeller.
Client Server Architektur
Virtual Earth Visualisierung von Geodaten Daniel Walzenbach, Microsoft Deutschland GmbH
Template v5 October 12, Copyright © Infor. All Rights Reserved.
Cyber-Security und Datenschutz in der Cloud Wie passt das zusammen?
Univ.-Lektor Dipl.-Ing. Dr. Markus Schranz staatlich befugter und beeideter Ingenieurkonsulent für Informatik Web Application Engineering & Content Management.
SAP Protects its Valuable Innovations Alexandra Koseva/ Intellectual Property Department at SAP Labs Bulgaria November 29, 2012.
Softwaresponsoren Mediasponsoren. Vorstellung KnowledgeCenter Neue Sprachfeautres in VB 9.0 LINQ to SQL in der Praxis.
Office Business Anwendungen mit SharePoint Fabian Moritz | MVP Office SharePoint Server.
Design Patterns Ein Muster (pattern) ist eine Idee, die sich in einem praktischen Kontext als nützlich erwiesen hat und dies auch in anderen sein wird.
Informations-Forum: SAP Interoperabilität
Microsoft Cloud Day Herzlich willkommen!. Microsoft Cloud Day MSDN Veranstaltung Die Cloud Plattform als Erfolgsbaustein – Wie Sie als Softwarefirma von.
Die nächste Generation von Microsoft Office System 2007 Microsoft Office System Gernot Kühn Technologieberater Office System Mittelstandsbetreuung.
Torque in Turbine Team 3 Alexander Mittermair Michael Wesinger.
Developer Day Deep Dive into WinRT-Controls: FlipView, ListView, GridView and SemanticZoom Thomas Claudius Huber Principal Consultant, Trivadis AG
Thomas Claudius Huber Senior Consultant Trivadis AG WCF RIA Services Datengetriebene Apps.
Launch ON Global.vi System ID object name classname Services to suscribe Observer Control Ref vi-path Service name Step 1 : Objects register to the Global.vi´s,
SQL Server 2005 CLR Integration Sebastian Weber Microsoft Deutschland GmbH
Martin Rink, SAP Trust Center Services SAP Trust Center Services SAP Passports - Scenarios of Usage.
Sprachneuerungen des .NET Frameworks 3.5
Ralf M. Schnell Technical Evangelist Microsoft Deutschland GmbH
Ralf M. Schnell Technical Evangelist Microsoft Deutschland GmbH.
Arbeiten in einem agilen Team mit VS & TFS 11
Azure Mobile Services Deep dive into node.js scripting
 Präsentation transkript:

Datenbankprogrammierung von DAO nach ADO Tilo Böttcher, Technology Specialist Hans Brender, Presales Consultant tiloboet@microsoft.com Microsoft GmbH

Von DAO nach ADO Agenda Von ISAM und RDBMS? DAO vs. ADO, ADOX und JRO Tuning und Objektorientierung Code-Migration und Fehlerquellen

OLE DB Provider for SQL Server ActiveX Data Objects (ADO) Von DAO nach ADO warum ein Wechsel nötig ist/sein wird, mehrschichtige Applikationen OLE DB Provider for SQL Server ActiveX Data Objects (ADO) RDS/HTTP VB 3-Tier VB 2-Tier IE DHTML HTML 3.2 IIS Business Objects ADO/OLEDB Client RDS/DCOM Middle Tier Data SQL Server IIS/ASP Of course, As a platform vendor, our job is to listen closely to the needs of the development community. Our platforms live or die by the value they provide to developers. An operating system must be a great place to write applications, as it’s the applications that customers want. Microsoft has been evolving our Operating System offerings during the past decade as well. A decade ago, our Operating Systems were designed for single-tier non-distributed applications like Lotus 1-2-3 or Microsoft Word. In the early ‘90s, we incorporated networking support in our operating systems, and helped drive standards like ODBC that enabled client server computing. Windows NT however was designed for distributed enterprise class computing. Today, the requirements for a successful internet application are synonymous in many ways with the needs of enterprise computing. We are seeing a unification of a single architecture for both Internet and Enterprise computing. Windows NT 4 was a big step forward for Windows. NT 4 for the first time incorporated the services application developers needed to write n-tier applications. In particular, NT 4 included a rich set of services like COM, MTS, IIS, and MSMQ that made writing middle tier logic dramatically easier. With Windows NT 5 our goal is to be the best place for distributed n-tier applications.

Von DAO nach ADO warum ein Wechsel nötig ist/sein wird, verteilte und heterogene Daten Datenbank Spreadsheet Photos Mail Landkarten Dokumente SQL 7.0 Query Processor OLE DB Interface Directory Service Select top 10 SS.customer_ name, SS.sales, Excel.sales_plan, Oracle.DSO, Mail.call_reports, Access.Entertainment_budget From SS.cust_sales, Excel.budget_worksheet, Oracle.receivables, Mail.my_mail_folder, Access.Entertainment Where SS.sales and SS.cust = Excel.cust and SS.cust = Oracle.cust SS.cust = Mail.cust SS.cust = Access.cust Order by SS.sales

Von DAO nach ADO warum ein Wechsel nötig ist/sein wird, Analyse zur Laufzeit online/offline - OLAP OLAP Server OLEDB/ADO Client Tier MD ActiveX Controls MD Erweiterung für OLE DB Office Schnittstellen 3rd Party Clients OLAP Server Tier MD Daten-Modellierung MD Calculation Engine Multidimensionaler Cache OLEDB/ODBC Data Warehouse Tier DW Management Plato MD Cache (HOLAP) SQL Server (ROLAP) 3rd Party Datenspeicher

Von DAO nach ADO Agenda Von ISAM nach RDBMS? DAO vs. ADO, ADOX und JRO Tuning und Objektorientierung Code-Migration und Fehlerquellen

Von DAO nach ADO Von ISAM nach RDBMS? ISAM-Dateien (Indexed Sequential Access Method) Jet/Access, Lotus RDBMS (Relationelles DatenBank Management-System) SQL

Von DAO nach ADO Warum gerade ADO? Vereinfachtes Objektmodell via OLE DB Verwendung von VARIANTS (VB oder Type-Mapping) Bei Benutzung von Visual C++ #import Methode verwenden Neue ADO Komponenten zur einfachen Benutzung Optimiert für Visual Basic Speichermanagement verbessert durch Aufspaltung in mehrere Komponenten Bestimmung der Datenlokalität, Speicherverwendung und Datentypen

Von DAO nach ADO Von ISAM nach RDBMS? Warum gerade ADO? Applikations-Schnittstelle ADO OLE DB DAO RDBMS JET ODBC API RDO SQL 7.0 ODBC Direct ADO ADOX JRO

Von DAO nach ADO Von ISAM nach RDBMS? SQL Datenbanken im Vergleich Aspekt SQL 6.5 SQL 7.0 MSDE Maximale Größe 1 Terabyte 1,048,516 Terabyte 2 Gigabytes Maximale Verbindungen Unlimited (Tuned for 5) Anzahl DBs 32,767

Von DAO nach ADO Von ISAM nach RDBMS Von DAO nach ADO Von ISAM nach RDBMS? Access 2000 ADP Objekte, ein Kompromiss beim Umstieg? Tabellen Sichten Datenbankdiagramme Gespeicherte Prozeduren Formulare/Berichte Seiten Makros Module

Von DAO nach ADO Von ISAM nach RDBMS Von DAO nach ADO Von ISAM nach RDBMS? Access 2000 ADP Objekte, ein Kompromiss beim Umstieg? MSDE / Desktop unterstützt nicht: Parallele Abfragen Planung im Fibermodus Read-Ahead-Scans Hash- und Mergeverknüpfungen Fail-Over-Cluster Erweiterungsspeicher

Von DAO nach ADO Agenda Von ISAM nach RDBMS? DAO vs. ADO, ADOX und JRO Tuning und Objektorientierung Code-Migration und Fehlerquellen

Von DAO nach ADO DAO vs. ADO, ADOX und JRO Ein kleiner ADO Überblick Eigenschaften: Scrolling cursors Fabricated data caches Disconnected caching Rich data-oriented services Sort, filter, find Multiple-tier deployment & configuration Remoting of data via HTTP and DCOM Business object integration persistent RecordSets (auch XML >= 2.1) Architektur: Connection Command Recordset Errors Fields Parameters

Von DAO nach ADO DAO vs. ADO, ADOX und JRO Ein kleiner ADO Überblick Eigenschaften: ADO ist sprachunabhängig, da als COM inproc Server implementiert (VB, VC++, VJ++, ASP ...) Zugriff auf unterschiedlichste relationale und nicht relationale Daten (SQL-Server, Oracle, DB2, Access, Active Directory, Index Server ...) Abstraktion erfolgt über den unterliegenden OLE DB Provider; ADO Programming Model bleibt gleich (Robust gegen Änderungen)

Von DAO nach ADO DAO vs. ADO, ADOX und JRO Ein kleiner ADO Überblick Shipped mit Visual Studio 6.0 Shipped mit NT 4.0 Service Pack 4 (2.0 SP1, kein standalone Setup) ADO 2.1 Shipped mit SQL Server 7.0 Shipped mit Office 2000 Dokumentation nur mit Office 2000 Dokumentation Online unter msdn.microsoft.com\library ADO 2.5 Shipped mit Windows 2000 Shipped als MDAC 2.5 (derzeit nur US) www.microsoft.com\data für Updates und News zu UDA

Von DAO nach ADO DAO vs. ADO, ADOX und JRO, die wichtigsten ADO Eigenschaften (2.1) Data Source Links Persistence in XML Client Cursor resync und auto-resync Dynamic Properties Index “on the fly” ADOX Für Schema Erzeugung und Manipulation (DDL) und Security DDL als First Class Objekte (Schema Manipulation auch via Execute möglich) Auf Microsoft Access resp. JET fokusiert Zugang zu DAO Objekten über ADO Programming Model JRO Nur ACCESS resp. JET/DAO Replica erzeugen und synchronisieren Replica Priority CompactDatabase mit Passwort Proctection und Encryption JET Cache Refresh Sync. zwischen MDB und SQL Server Publication möglich

ADO 2.1 Core Data Source Links (DSL) UI um Connect Information zu setzen und persistent zu machen FILE NAME=C:\myudls\sql7.udl bei Open Teil von OLEDB VB ADO Controls können DataSource via DSL File instanziieren Über OLEB via IDataInitialize und/oder IDBPromptInitialize Demo

ADO 2.1 Core Client Cursor Resync Für static oder forward-only Cursor um Änderungen in der Datenbank zu sehen Kein Requery, d.h. neue Records werden nicht angezeigt Errors Collection und adFilterConflictRecords verwenden um gelöschte Einträge zu erkennen Destructive und non destructive adResyncAll (default) Daten werden überschrieben adResyncUnderlyingValues

ADO 2.1 Core Persistence in XML In ADO 2.0 nur als File Für Offline Operationen Client Cursor muss verwendet werden (adUseClient) Offline Änderungen werden ebenfalls persistiert Änderungen können später via UpdateBatch commited werden Demo

ADO 2.1 Core Dynamic Properties “Name” Property Namen für einen Recordset Wird in der Properties Collection abgespeichert Erfordert adUseClient “Update Resync” Property Gibt an ob bei einem UpdateBatch eine Resync erfolgt und welcher Art dieser ist

ADO 2.1 Core Index “on the fly” CursorLocation muss adUseClient sein Bestandteil der Field Properties Collection Internal für ADO z.B. Index für Sort und Filter Operation Wert Field.Properties(“Optimize”) = TRUE Field.Properties(“Optimize”) = FALSE

ADOX Für Schema Erzeugung und Manipulation (DDL) und Security DDL als First Class Objekte (Schema Manipulation auch via Execute möglich) Auf Microsoft Access resp. JET fokussiert Zugang zu DAO Objekten über ADO Programming Model

ADOX Objekte Catalog Table User Group View Procedure Key Index Column Bis auf Catalog sind alle Objekte auch als Collections vorhanden Table, Column und Index haben zusätzlich noch eine Properties Collection

Jet und Replication Objects Objekte JetEngine Replica Filter Collections Filters

Jet und Replication Objects JetEngine Object CompactDatabase RefreshCache Replica Object CreateReplica MakeReplicable Synchronize PopulatePartial Filter Object TableName, Filter, FilterType Properties

Von DAO nach ADO DAO vs. ADO, ADOX und JRO Bereiche Öffnen der Datenbank Datenmanipulation Anlegen und Bearbeiten der Datenbankschema Sicherheit Replikation Fehler(teufel) abfangen

Von DAO nach ADO DAO vs. ADO, ADOX und JRO; Öffnen der Datenbank Sub OpenJetDatabase() Dim db As DAO.Database Set db = DBEngine.OpenDatabase("C:\Nwind.mdb") db.Close End Sub Sub OpenJetDatabase() Dim cnn As New ADODB.Connection cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Nwind.mdb;" cnn.Close End Sub Sub OpenSecuredDatabase() Dim wks As DAO.Workspace Dim db As DAO.Database DBEngine.SystemDB = "nwindsysdb.mdw" Set wks = DBEngine.CreateWorkspace("", "Admin", "password") Set db = wks.OpenDatabase("c:\nwind.mdb") End Sub Sub OpenSecuredDatabase() Dim cnn As New ADODB.Connection cnn.Provider = "Microsoft.Jet.OLEDB.4.0" cnn.Properties("Jet OLEDB:System database") = "nwindsysdb.mdw" cnn.Open "Data Source=c:\nwind.mdb;User Id=Admin;Password=password;" End Sub Sub DAOOpenISAMDatabase() Dim db As DAO.Database Set db = DBEngine.OpenDatabase("C:\Sales.xls", _ False, False, "Excel 5.0;") db.Close End Sub Sub OpenISAMDatabase() Dim cnn As New ADODB.Connection cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data _ Source=C:\Sales.xls;Extended Properties=Excel 5.0;" cnn.Close End Sub

Von DAO nach ADO DAO vs. ADO, ADOX und JRO; Datenmanipulation Sub OpenRecordset() Dim db As DAO.Database Dim rst As DAO.Recordset Dim fld As DAO.Field 'Open the database Set db = DBEngine.OpenDatabase("C:\nwind.mdb") 'Open the Recordset Set rst = db.OpenRecordset("Select * from Customers where Region" & _ ' = WA'", dbOpenSnapshot, dbOpenForwardOnly) ' Display the records in the debug window While Not rst.EOF For Each fld In rst.Fields Debug.Print fld.Value & ";"; Next Debug.Print rst.MoveNext Wend 'Close the recordset rst.Close End Sub Sub OpenRecordset() Dim cnn As New ADODB.Connection Dim rst As New ADODB.Recordset Dim fld As ADODB.Field ' Open the connection cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\nwind.mdb;" ' Open the forward-only, read-only recordset rst.Open "Select * from Customers where Region = 'WA'", cnn, _ adOpenForwardOnly, adLockReadOnly ' Display the records in the debug window While Not rst.EOF For Each fld In rst.Fields Debug.Print fld.Value & ";"; Next Debug.Print rst.MoveNext Wend 'Close the recordset rst.Close End Sub

Von DAO nach ADO DAO vs. ADO, ADOX und JRO; Anlegen und Bearbeiten von Datenbankschemata Sub CreateDatabase() Dim db As New DAO.Database Set db = DBEngine.CreateDatabase "C:\new.mdb;", dbLangGeneral, End Sub Sub CreateDatabase() Dim cat As New ADOX.Catalog cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\new.mdb;" End Sub Sub DAOListTables() Dim db As DAO.Database Dim tbl As DAO.TableDef ' Open the database Set db = DBEngine.OpenDatabase("C:\nwind.mdb") ' Loop through the tables in the database and print their name For Each tbl In db.TableDefs Debug.Print tbl.Name Next End Sub Dim cat As New ADOX.Catalog Dim tbl As ADOX.Table ' Open the catalog cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=c:\nwind.mdb;" ' Loop through the tables in the database and print their name For Each tbl In cat.Tables If tbl.Type <> "VIEW" Then Debug.Print tbl.Name Next End Sub

Von DAO nach ADO DAO vs. ADO, ADOX und JRO; Anlegen und Bearbeiten von Datenbankschemata Sub DAOCreateTable() Dim db As DAO.Database Dim tbl As DAO.TableDef 'Open the database Set db = DBEngine.OpenDatabase("C:\nwind.mdb") ' Create a new TableDef object. Set tbl = db.CreateTableDef("Contacts") With tbl ' Create fields and append them to the new TableDef object. ' This must be done before appending the TableDef object to ' the TableDefs collection of the database. .Fields.Append .CreateField("FirstName", dbText) .Fields.Append .CreateField("LastName", dbText) .Fields.Append .CreateField("Phone", dbText) .Fields.Append .CreateField("Notes", dbMemo) End With ' Add the new table to the database. db.TableDefs.Append tbl db.Close End Sub Dim cat As New ADOX.Catalog Dim tbl As New ADOX.Table ' Open the catalog cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\nwind.mdb;" ' Create a new TableDef object. With tbl .Name = "Contacts" ' Create fields and append them to the new TableDef ' object. This must be done before appending the ' TableDef object to the TableDefs collection of the ' database. .Columns.Append "FirstName", adVarWChar .Columns.Append "LastName", adVarWChar .Columns.Append "Phone", adVarWChar .Columns.Append "Notes", adLongVarWChar End With ' Add the new table to the database. cat.Tables.Append tbl Set cat = Nothing End Sub

Von DAO nach ADO DAO vs. ADO, ADOX und JRO; Sicherheit Sub SetDatabasePassword() Dim db As DAO.Database Set db = DBEngine.OpenDatabase("C:\nwind.mdb", True) db.NewPassword "", "password" db.Close End Sub Sub SetDatabasePassword() Dim cat As New ADOX.Catalog cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=nwind.mdb;Mode=" & adModeShareExclusive cat.Modify "Jet OLEDB:Database Password=password;" End Sub Sub CreateUser() Dim wks As DAO.Workspace ' Open a workspace DBEngine.SystemDB = "c:\nwindsysdb.mdw" Set wks = DBEngine.CreateWorkspace("", "Admin", "password") ' Create the user and append it to the Users collection wks.Users.Append wks.CreateUser("User1", "User001", "password") End Sub Sub CreateUser() Dim cat As New ADOX.Catalog ' Open the catalog, specifying the system database to use cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\nwind.mdb;" & _ "Jet OLEDB:System database=C:\nwindsysdb.mdw;" & _ "User Id=Admin;Password=password;" ' Create the new user and append it to the users collection cat.Users.Append "NewUser", "password", "User001" End Sub

Von DAO nach ADO DAO vs. ADO, ADOX und JRO; Replikation ADO/JRO Sub MakeDesignMaster() Dim dbsNorthwind As DAO.Database Dim prpNew As DAO.Property ' Open database for exclusive access. Set dbsNorthwind = DBEngine.OpenDatabase("Northwind.mdb", True) With dbsNorthwind ' If Replicable property doesn't exist, create it. ' Turn off error handling in case property exists. On Error Resume Next Set prpNew = .CreateProperty("Replicable", dbText, "T") .Properties.Append prpNew ' Set database Replicable property to True. .Properties("Replicable") = "T" .Close End With End Sub Sub MakeDesignMaster() Dim repMaster As New JRO.Replica ' Make the Northwind database replicable. ' If successful, this will create a connection to the ' database. repMaster.MakeReplicable "Northwind.mdb", False Set repMaster = Nothing End Function

Von DAO nach ADO Agenda Von ISAM nach RDBMS? DAO vs. ADO, ADOX und JRO Performancetuning und Objektorientierung Code-Migration und Fehlerquellen

Von DAO nach ADO Performance Cursor Connection “rules”. Wird für einen RecordSet keine “CursorLocation” gesetzt erhält dieser die Einstellung auf Connection Basis Für remotable Recordsets muss dies “adUseClient” sein Bei incompatiblen Cursoreinstellungen versucht der Provider einen “best guess” zu machen. Default: Connection --> adUseServer Recordset --> adUseServer Scroll: adOpenForwardOnly Isolation: adLockReadOnly Für Remotable Connection --> adUseClient RecordSet --> erhält Setting von Conncetion Object oder explizit setzten Scoll: odOpenDynamic oder adOpenKeyset Isolation: adLockBatchOptimistic

Von DAO nach ADO Performance Connection “Teuer”, vor allem bei Web Applikationen Asynchron ist O.K. aber nicht für 3-Tier Applikationen Connection Objekte sollten bei einer Web App nicht im Session Object abgespei-chert werden Connection immer explizit erzeugen  “under the hood” Connections nicht poolable Abhilfe --> Connection Pooling

Von DAO nach ADO Performance ODBC Connection Pooling Einstellung über die Registry In neueren ODBC Versionen über den ODBC Service Manager Default Timeout ist 60 Sekunden Anfangspoolgrösse ist nicht konfigurierbar Num. Pools = Num. Procs. + 1 Reuse aus dem Pool nur, wenn “alle” Einstellungen übereinstimmen Änderungen auf Connection Ebene, welche z.B. das Serververhalten beeinflussen werden nicht abgespeichert (SET, USE ...) --> DON’T DO THAT!! OLE DB Resource Pooling Für native OLE DB Provider Als OLE DB Service Provider implementiert Num Pools = (Num. Procs. + 1 ) * Num. unterschiedliche Benutzer “Services” werden über Bit Values in der Registry definiert (Q191745) Timeout ebenfalls 60 Sekunden Anfangspool ebenfalls nicht konfigurierbar Keine SET USE etc. Kommandos welche das Serververhalten beeinflussen könnten

Von DAO nach ADO Performance Command und Connection Asynchrone Operationen (default ist synchron) 3 Möglichkeiten adAsyncExecute: ADO führt Command in einem zweiten Thread aus, über ExecuteComplete erfolgt die Notification adAsynchFetch: Zweiter Thread, bei einem Fetch wird solange geblockt bis der Datensatz gelesen ist. adUseClient als CursorLocation adAsyncFetchNonBlocking: Niemals Blocking, wenn ein Fetch auf einen Datensatz erfolgt der noch nicht da ist, erfolgt eine MoveEOF; im nächsten Fetch werden dann die Daten vorhanden sein. adUseClient als CursorLocation erforderlich

Von DAO nach ADO Performance Commands Beste Performance über Stored Procedures Parameter im Code definieren (nicht über Refresh, extra Roundtrip zum Server) Command Typ angeben Asynchron wenn angebracht adExecuteNoRecords Prepare - Falls es Sinn macht Wenn der Typ nicht angegeben wird, versucht ADO über “Try and Error” den Typ zu erkennen Reihenfolge: aCmdText, adCmdTable, adCmdStoredProc, adCmdFile Set cmd.ActiveConnection = cnn ‘Opening a table directly cmd.CommandType = adCmdTable Set rst = cmd.Execute(“authors”) ‘Executing a proc that doesn’t return results cmd.CommandType = adCmdStoredProc + adExecuteNoRecords cmd.Execute “sp_insert”

Von DAO nach ADO Objektorientierung Kapselung von logischen Einheiten in Klassen – keine direkte Datenbindung an GUI-Elemente (siehe Demo) Arbeit mit zwei oder drei Schichten Gepufferter Zugriff auf typisierte Daten Klasse 1 Form1 Dim obj01 as new class1 Dim obj02 as new class3 Klasse 2 Klasse 3 Form2 Dim obj01 as new class1 Dim obj02 as new class2 Benutzerschicht Anwendungsschicht

Von DAO nach ADO Agenda Von ISAM nach RDBMS? DAO vs. ADO, ADOX und JRO Tuning und Objektorientierung Code-Migration und Fehlerquellen

Von DAO nach ADO Code Migration und Fehlerquellen DEMO

Links und Newsgroups http://www.microsoft.com/germany/msdn/techtalk http://www.microsoft.com/germany/data http:// msdn.microsoft.com/library http://www.microsoft.com/AccessDev/ProdInfo/AUT97dat.htm http://www.vba-magazin.de/ http://www.basicworld.com/ Newsgroups Server msnews.microsoft.com microsoft.public.de.germany.entwickler.techtalk microsoft.public.de.germany.entwickler.techtalk.office2000

Informationen von Microsoft Press http://www.microsoft.com/germany/mspress Datenbankprogrammierung mit Visual Basic 6 Autor: Walter Doberenz, Thomas Kowalski ISBN: 3-86063-485-2 Umfang: 633 Seiten Preis: 79,00 DM ADO-Programmierung Autor: David Sceppa ISBN: 3-86063-618-9 Umfang: 384 Seiten Preis: 79,00 DM   Artikel: Migrating from DAO to ADO (Using ADO with the Microsoft Jet OLE DB Provider) Alyssa Henry Msdn Library

This document is for informational purposes only This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. 2000 Microsoft Corporation. All rights reserved. Companies, names, and/or data used in screens and sample output are fictitious, unless otherwise noted. Microsoft, Windows, and Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. Other product and company names mentioned herein may be the trademarks of their respective owners.