La presentazione è in caricamento. Aspetta per favore

La presentazione è in caricamento. Aspetta per favore

Oracle & SQL Server in a .NET World

Presentazioni simili


Presentazione sul tema: "Oracle & SQL Server in a .NET World"— Transcript della presentazione:

1 Oracle & SQL Server in a .NET World
3/27/2017 2:28 AM Oracle & SQL Server in a .NET World Silvano Coriani Developer Evangelist Microsoft © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

2 Agenda Il miglior RDBMS per .NET 
Microsoft SQL Server 2005 Ok, ok…viviamo in un mondo “meticcio”  Oracle 8i/9i/10g (10.1.0,10.2.0) IBM DB2 UDB 8.2.2 .NET Development Problemi simili, ambienti e soluzioni diverse Best practices e dintorni

3 RDBMS su Windows Intendiamoci… Microsoft SQL Server 2005 è il miglior RDBMS su Windows Miglior TPC-C su hw commerciale (x86-IA64) Migliori risultati su processori (x86) Ha il Query Processor più evoluto Miglior integrazione con la piattaforma di sviluppo Semplicità di gestione “Auto-everything” da sempre News con la versione 2005 Uno Storage Engine all’altezza di qualsiasi confronto Nuovi servizi integrati come il Broker, Notifications, ecc.

4 RDBMS su Windows Ma non siamo soli… 
Oracle, dalla 8i alla 10g (10.2.0) Pro (cosa gli invidio) La reputazione  e il know how Lo storage engine Contro Query Proc “solido” ma non particolarmente smart Costi licenze comunque elevati, e componenti aggiuntive a pagamento Complessità di gestione (capacity planning, installazione, tuning, amministrazione) IBM DB 2 Pro Query proc decisamente interessante Il TPC-C benchmark su AIX e POWER5  Versioni differenti sulle diverse piattaforme Funzionalità, comportamenti, modelli di programmazione Strumenti di gestione “incoerenti” Servizi poco integrati tra di loro

5 RDBMS su Windows Ma in Oracle si fa…. come faccio in SQL Server?
Nello Storage Engine di SQL Server 2005 ci sono novità per i DEV che utilizzano normalmente Oracle Snapshot Isolation (e Read Committed S.I.) Data & index partitioning È stato aggiunta la funzione ROW_NUMBER() per numerare i record di un resultset (evvai con le paginazioni!)  Altre tecniche di programmazione tipiche del mondo Oracle possono essere facilmente imitate con SQL Server Ad esempio le famigerate Sequence

6 Estendere il DBMS “dall’interno” con .NET
SQL Server 2005 integra il CLR per estendere il DBMS Sia Oracle che DB2 consentono l’utilizzo di estendere il motore relazionale con il codice managed, in modalità diverse Utilizzano la v1.1 del CLR Integrazione molto diversa rispetto a SQL Server 2005 Semplice hosting attraverso le interfacce COM del CLR Nessun utilizzo degli host attributes della v2.0 per garantire la stabilità dell’hoster (utilizzo delle risorse, gestione eccezzioni, ecc.) Es. Oracle CLR Host

7 Windows Development Environment Support
3/27/2017 2:28 AM Windows Development Environment Support Oracle Developer Tools for VS.NET IIS (ASP ASP.NET) MTS/ COM+ C++, C#, VB .NET Application Develop Deploy Visual Studio Environment Application IIS Deploy Database Development ODP.NET Oracle DB Extensions For .NET Oracle Services for MTS © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

8 Sviluppare applicazioni “client” con .NET
Strumenti .NET Data Providers di Microsoft, Oracle e IBM Oracle Developer Tools for Visual Studio .NET IBM DB2 Tools for Visual Studio .NET Reusable code Enterprise Library Data Access Application Blocks Oracle DB2 Problemi aperti Differenti dialetti SQL Ma standard ANSI-SQL 92 più o meno rispettato Differenti funzionalità Sequence, Locking model, Stored Proc, supporto XML, ecc. ecc.

9 Oracle e .NET sul client Microsoft .NET Data Provider per Oracle
3/27/2017 2:28 AM Oracle e .NET sul client Microsoft .NET Data Provider per Oracle Prodotto da Microsoft Usa gli strumenti client di Oracle Oracle Data Provider per .NET (ODP.NET) Sviluppato da Oracle Integrazione completa Espone tutte le caratteristiche di un Oracle DB Oracle Connect per .NET (DataDirect) Altri metodi di accesso OLE DB .NET via OLE DB ODBC .NET via ODBC © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

10 ODP.NET Basics Disponibile gratuitamente Supporta VS.NET 2002 e 2003
.NET Developer Center Può essere usato con Oracle8, Oracle8i, Oracle9i, e Oracle10g Il database server può essere su Unix, Linux, Windows, etc. Client basato su .NET Supporta VS.NET 2002 e 2003 Supporta .NET Framework 1.0 e 1.1 © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

11 .NET Data Providers 3/27/2017 2:28 AM
Your choices for connecting to Oracle with ADO.NET consist of the OleDb data provider, the Odbc data provider, or a native data provider. When you use the OleDb or Odbc data providers, there's an extra level of indirection through the OLE DB provider or ODBC driver. Microsoft's and Oracle's data providers use the OCI libraries; DataDirect's driver uses the TNS protocol directly. © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

12 ODP.NET Layer Layer Connesso Dati Disconnesso (ODP.NET) DataSet Oracle
3/27/2017 2:28 AM ODP.NET Layer Disconnesso Layer Connesso (ODP.NET) Dati Oracle DataAdapter OracleCommand Builder DataSet Oracle DataReader Oracle Command Oracle Transaction Oracle Connection Oracle © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

13 ODP.NET Supporto completo a PL/SQL Data type nativi Oracle
3/27/2017 2:28 AM ODP.NET Supporto completo a PL/SQL Packaged, non-packaged, anonymous, autonomous *Batch SQL disponibile con anonymous PL/SQL Data type nativi Oracle LOBS, REF Cursors, BFiles, N-data types, Dates, TimeStamps, Longs, Raws, etc. Mapping con tipi .NET *Connection pooling Min, Max, Timeout, Lifetime, Increment, Decrement © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

14 Integrazione con Visual Studio .NET
3/27/2017 2:28 AM Integrazione con Visual Studio .NET Dynamic Help Documentazione ODP.NET – F1 key Server Explorer Tables, views, e synonyms Query e view designer Stored procedures, functions, triggers, package bodies, package specifications Execute, create, delete Intellisense Drag-and-drop da Data toolbox © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

15 .NET e Oracle ADO.NET VS.NET 2003 ASP.NET Web Services ODBC.NET OleDB
3/27/2017 2:28 AM .NET e Oracle ADO.NET ODBC.NET OleDB Oracle ODP.NET VS.NET 2003 ASP.NET Web Services How to access Oracle through .NET? Classic ADO with COM interop. ADO.NET and its various Providers Visual Studio .NET 2003—code-named Everett and based on .NET version 1.1—adds significant new features to the GUI-based designer tools for Oracle databases. These features appear in the Server Explorer and in the drag-and-drop items in the Visual Studio Data toolbox tab. You'll notice the difference whether you use the Oracle 8i or the Oracle 9i database, but I'll concentrate on explaining how to use these features with 9i, because the improvements are much more noticeable if you work with this version. © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

16 Usare ADO.NET con Oracle
3/27/2017 2:28 AM Usare ADO.NET con Oracle Imports System.Data Imports System.Data.OracleClient Sub Main() Dim conn as New OracleConnection() conn.ConnectionString = _ "data source=zzz;" & _ "user id=scott;password=tiger" Try conn.Open() Console.WriteLine("Hello Oracle") Catch e as Exception Console.WriteLine("Failed connect") Finally If conn.State = _ ConnectionState.Open Then conn.Close() End If conn.Dispose() End Try End Sub Sub UseDataReader() Dim conn as New OracleConnection() conn.ConnectionString = _ "data source=symbolicname;" & _ "user id=scott;password=tiger" Dim cmd As New OracleCommand( _ "select * from emp", conn) Dim rdr As OracleDataReader Try conn.Open() rdr = cmd.ExecuteReader() While rdr.Read = True Console.WriteLine( _ "empno = {0}, ename = {1}", _ rdr("empno"), rdr("ename")) End While Catch e As Exception Console.WriteLine(e.Message) Finally If conn.State = _ ConnectionState.Open Then conn.Close() End If cmd.Dispose() conn.Dispose() End Try End Sub This simple program executes a SQL SELECT statement and retrieves a resultset through an OracleCommand and OracleDataReader. Note that you should call Dispose on the OracleCommand, as well as the OracleConnection, when you're finished with it. © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

17 3/27/2017 2:28 AM Oracle e i DataSet Sub UseDataSet() Dim ds As New DataSet() Dim da As New OracleDataAdapter( _ "select * from emp", _ "data source=zvm43;" & _ "user id=tiger;password=tiger") Dim bld As New OracleCommandBuilder(da) Try da.Fill(ds, "emp") Dim r As DataRow For Each r In ds.Tables(0).Rows Console.WriteLine( _ "empno = {0}, ename = {1}", _ r("empno"), r("ename")) Next ' Change a row and call Update ds.Tables(0).Rows(0)(2) = "JONES" da.Update(ds, "emp") Catch e As Exception Console.WriteLine(e.Message) End Try End Sub © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

18 3/27/2017 2:28 AM Query parametriche “Select * from emp where empno > ?” (ODBC,OleDB,DataDirect) “Select * from emp where empno (System.Data.SqlClient) “Select * from emp where empno > :enumber” (System.Data.OracleClient) Sub UseParmQuery() Dim conn As New OracleConnection( _ "data source=zmv43;" & _ "user id=scott;password=tiger") Dim cmd As New OracleCommand( _ "select * from emp " & _ "where empno > :thenumber", conn) cmd.Parameters.Add("thenumber", 7000) Dim rdr As OracleDataReader Try conn.Open() rdr = cmd.ExecuteReader() While rdr.Read = True Console.WriteLine( _ "empno = {0}, ename = {1}", _ rdr("empno"), rdr("ename")) End While Catch e As Exception Console.WriteLine(e.Message) Finally If conn.State = _ ConnectionState.Open Then conn.Close() End If cmd.Dispose() conn.Dispose() End Try End Sub © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

19 Funzionalità specifiche ODP.NET
3/27/2017 2:28 AM Funzionalità specifiche ODP.NET Stessi nomi di classi dei provider Microsoft e DataDirect Ottimizzazioni sulle connessioni Gestione dei Savepoint nelle transazioni locali e distribuite REF CURSORs BLOB, CLOB, BFILE Use the Oracle Data Provider for .NET (ODP.NET) to extend the base ADO.NET interfaces and base classes to put almost all the functionality the Oracle database offers within reach. ODP.NET allows you to expose Oracle-specific behaviors and optimize access in Oracle-specific .NET applications. Using database-specific ADO.NET data providers is almost always preferable to using the OLE DB and ODBC bridge providers (see the sidebar, "Let a Hundred Providers Bloom"). However, writing optimized code for the target database requires you to understand how different data providers work. I will examine ODP.NET's features and compare it to the SqlClient data provider. Along the way, I'll explain downloadable program examples that put ODP.NET to use. This article is based on the 1.0 release of ODP.NET (see Additional Resources). ADO.NET data providers implement provider-specific classes that implement common interfaces. Some of these classes extend base classes in the .NET Framework. The dataprovider classes implemented in ODP.NET are part of the Oracle.DataAccess.Client namespace (see Table 1). A data provider must also map database data types to the .NET type system (see the sidebar, "Use ODP.NET to Help Map Data Types"). It can expose database-specific classes to map more closely if no .NET types are an exact fit. ODP.NET exposes a series of extended data types in the Oracle.DataAccess.Types namespace. Some of these are implemented as value types (structures, in C#), because .NET value types provide optimizations over making every type a class; others are implemented as reference types (classes) (see Figure 1). ODP.NET supports two types of special data-related classes in the Oracle.DataAccess.Types namespace. Large objects and REF CURSOR types are Object types derived from System.Stream. The remaining special types are derived from System.ValueType to take advantage of stack-based allocation semantics. ODP.NET's optimizations for accessing Oracle functionality start at the beginning—the connection. The easiest way to optimize connections in a three-tier environment is by pooling. Unlike the bridge providers, which use OLE DB or ODBC's built-in connection pooling, ODP.NET allows you to specify pooling parameters on the connection string. Use the Max Pool Size and Min Pool Size parameters to specify the maximum and minimum number of open connections in a pool. If you set ODP.NET's Min Pool Size to 5, the provider opens a single connection the first time Connection.Open is called, returns to the caller immediately, then uses a background thread to open the other four connections. If a pool is at Max Pool Size, the provider (and the caller) wait for the amount of time specified in OracleConnection.ConnectionTimeout for a connection to become available. The default value for ConnectionTimeout is 15 seconds. An exception is raised if no connection is available at that point. You can also use the Increment and Decrement connection string parameters to specify the number of connections that are opened or closed at a time, when the number of connections falls between MinPoolSize and MaxPoolSize. © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

20 REF CURSOR come Resultset
3/27/2017 2:28 AM REF CURSOR come Resultset OracleConnection conn = new OracleConnection( "data source=zmv43;user id=scott;password=tiger"); OracleCommand cmd = new OracleCommand("Employes.GetEmpRecords", conn); cmd.CommandType = CommandType.StoredProcedure; conn.Open(); cmd.Parameters.Add("p_cursor", OracleDbType.RefCursor); cmd.Parameters.Add("j_cursor", OracleDbType.RefCursor); cmd.Parameters.Add("indeptno", OracleDbType.Decimal); cmd.Parameters.Add("p_errorcode", OracleDbType.Int32); cmd.Parameters[0].Direction = ParameterDirection.Output; cmd.Parameters[1].Direction = ParameterDirection.Output; cmd.Parameters[2].Value = 10; cmd.Parameters[3].Direction = ParameterDirection.Output; OracleDataReader rdr = cmd.ExecuteReader(); // fetch output parm Console.WriteLine(cmd.Parameters[3].Value); do { while (rdr.Read()) Console.WriteLine(rdr[0]); } while (rdr.NextResult() == true); © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

21 ExecuteNonQuery e REF CURSORS
3/27/2017 2:28 AM ExecuteNonQuery e REF CURSORS // Connection and parameter setup as above ... int i = cmd.ExecuteNonQuery(); // cast to obtain both REF CURSORs as DataReaders OracleDataReader rdr1 = ((OracleRefCursor)cmd.Parameters[0].Value).GetDataReader(); OracleDataReader rdr2 = ((OracleRefCursor)cmd.Parameters[1].Value).GetDataReader(); // use both REF CURSORs at the same time while ((rdr1.Read()) && (rdr2.Read())) { Console.WriteLine(rdr1.GetName(0) + " = " + rdr1[0]); Console.WriteLine(rdr2.GetName(0) + " = " + rdr2[0]); } © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

22 ODP.NET e XML *XML XMLType data type Query XML dal DB
3/27/2017 2:28 AM ODP.NET e XML *XML XMLType data type Query XML dal DB Sia su tabelle relazionali che object-relational Interoperabilità con MS XML API (es. XmlReader) Supporta XSLT e XPATH There features are not available to ADO, OLE DB .NET, nor ODBC .NET users: ODP.NET XML APIs XML DB is a high performance XML storage and retrieval technology in the Oracle DB. XML DB stores XML natively in the DB with its own data type, XMLType. ODP.NET exposes XMLType as a native type within .NET to manipulate XML and share XML with Microsoft’s XML services, such as XMLReader. ODP.NET can access relational and object-relational data as XML with the ability to query and save XML from the database easily. * Performance tip © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

23 ODP.NET e XML Richiede Oracle8i, Oracle9i, o Oracle 10g DB XML DB
3/27/2017 2:28 AM ODP.NET e XML Richiede Oracle8i, Oracle9i, o Oracle 10g DB Può richiedere XML Developer’s Kits (XDK) sul server XML DB Non è indispensabile ma raccomandato Disponibilità di OracleXmlType Possibilità di utilizzare Schema XML © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

24 Classi ODP.NET XML OracleXmlType OracleXmlStream
Dati XMLType nativi OracleXmlStream Stream XML read-only OracleXmlQueryProperties OracleXmlSaveProperties © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

25 ODP.NET Transazioni Globalization Transparent application failover
3/27/2017 2:28 AM ODP.NET Transazioni Utilizzo degli Enterprise Services via Oracle Services for MTS Locali (Implicite e esplicite) Savepoints Globalization Supporto completo a Unicode Utilizzo delle impostazioni internazionali dei client Transparent application failover Callback di notifica Here are some of the ODP.NET features that were not previously available to ADO, OLE DB .NET, nor ODBC .NET users: Local transaction savepoints Globalization Transparent application failover (TAF) notification Savepoints creates intermediate points to which transactions can be rolled back to. That way, transactions do not need to be rolled back entirely, but can be rolled back partially. This reduces the time it takes for transaction recovery to occur. Savepoints are set off of the ODP.NET Transaction object. ODP.NET fully supports Unicode, which is important for making your applications available internationally. Moreover, globalization support allows developers to develop one set of code for any culture/language setting. ODP.NET globalization extracts the client computer’s national language setting to display information in the proper format. For example, a Japanese application can be deployed that shows currency in yen. Without having to do any new coding, that same application can be deployed in Germany and show deutsche marks. TAF notification allows ODP.NET developers to register TAF events that occur in the DB. TAF events allow developers to build more robust and interactive applications during DB connection loss and recovery. * Performance tip © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

26 Best Practice - Connection
3/27/2017 2:28 AM Best Practice - Connection Utilizzare il connection pooling Ma attenzione al numero di connessioni nel pool (nell’ultima versione di ODP.NET abbiamo pieno controllo) Attenzione alle stringe di connessione Non generare pool differenti Utilizzare forme di autenticazione “proxy” © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

27 Best Practice - Connection
3/27/2017 2:28 AM Best Practice - Connection Validate Connection Garantisce una connessione valida, ma al prezzo di un extra round trip Forse meglio crearsi il proprio exception handler Utilizzare correttamente gli oggetti ODP.NET (e.g. OracleConnection) Chiamare Dispose() quando non più utilizzati © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

28 Best Practice – Letture e aggiornamenti
Concetto base: controllare i roundtrip verso il database Recuperare solo i dati necessari, solo quando necessario SELECT Usare FetchSize (OracleDataReader) e RowSize (OracleCommand) per controllare la dimensione dei dati ritornati Utilizzare DataAdapter Requery Evita DB round trip © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

29 Best Practice – Letture e aggiornamenti
Multi-statement (in un roundtrip) Eseguire più statement batch differenti Attraverso anonymous PL/SQL Unico roundtrip, resultset differenti Stesso set di comanti più volte? Utilizzare statement caching Riutilizzo di comandi SQL o PL/SQL Ok anche quando il valore dei parametri cambia © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

30 Best Practice – Letture e aggiornamenti
Multi-statement Eseguire lo stesso comando più volte? Utilizzare il parameter array binding Il comando verrà eseguito una volta per ogni valore dell’array, ma in un unico roundtrip Limitazioni nell’utilizzo di SELECT statement, tipicamente adatto ad operazioni di insert/update Passare un array? Utilizzare gli array associativi di PL/SQL Il comando verrà eseguito una sola volta per l’intero array Ok anche per comandi di SELECT Parameter array binding Più semplice degli array associativi Ma gli array associativi hanno migliori performance e funzionalità avanzate © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

31 Best Practice – Data Type
3/27/2017 2:28 AM Best Practice – Data Type Concetto base: controllare i roundtrip Utilizzare I tipi esposti da ODP.NET (es. OracleClob) Utilizzare OracleRefCursor Recupero dei dati solo quando necessario Utilizzare Oracle LOB (DML) No roundtrip aggiuntivi per aggiornare o inserire LOB © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

32 Best Practice – Data Type
3/27/2017 2:28 AM Best Practice – Data Type Usare Oracle LOB (SELECT) Devo leggere tutto il LOB? InitialLOBFetchSize e InitialLongFetchSize per controllare l’attività Devo leggerne solo una parte? Proprietà Read per controllare la quantità di dati letti per roundtrip Devo leggere il contenuto successivamente? Di default, ODP.NET LOBs utilizzano puntatori agli oggetti sul server e non necessitano di rileggere interamente gli oggetti © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

33 Approfondimenti .NET Developer Center Portale Oracle su Windows
3/27/2017 2:28 AM Approfondimenti .NET Developer Center Portale Oracle su Windows © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

34 (partitioned across a cluster)
3/27/2017 2:28 AM .NET e la famiglia DB2 DB2 for zOS DB2 (partitioned across a cluster) DB2 (Linux for zSeries) .NET Application DB2 for VSE & VM DB2 (Windows & Linux) DB2 for iSeries DB2 (Linux for iSeries) DB2 Everyplace © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

35 OLE DB .Net Data Provider
3/27/2017 2:28 AM DB2 e ADO.NET sul client Application System.Data.OleDb Application Microsft.Data.ODBC Application IBM.Data.DB2 OLE DB .Net Data Provider OleDbConnection OleDbCommand OleDbAdapter OleDbDataReader ODBC .Net Data Provider OdbcConnection OdbcCommand OdbcDataAdapter OdbcDataReader DB2 .Net Data Provider DB2Connection DB2Command DB2DataAdapter DB2DataReader IBM DB2 OLE DB Provider IBM DB2 ODBC Driver DB2 © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

36 Data Provider per DB2 ODBC .NET Data Provider
3/27/2017 2:28 AM Data Provider per DB2 ODBC .NET Data Provider Per .NET Framework v1.0: Namespace = Microsoft.Data.Odbc download from MSDN per .NET Framework v1.1: Namespace = System.Data.Odbc OLE DB .NET Data Provider Namespace = System.Data.Oledb IBM DB2 .NET Data Provider Namespace = IBM.Data.DB2 Parte del DB2 Run-Time Client V8.1.2 © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

37 Modalità disconnessa System.Data IBM.Data.DB2 WinForm DataSet
3/27/2017 2:28 AM Modalità disconnessa System.Data IBM.Data.DB2 DB2 WinForm DataSet Table Data Adapter Data Adapter DB2 Data Adapter WebForm SQL Server Data Adapter Mobile WebForm Other Data Adapter © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

38 DB2Connection Object Supporto per connection pooling
3/27/2017 2:28 AM DB2Connection Object Supporto per connection pooling Può partecipare a transazioni distribuite Ricordarsi di chiudere la connessione quando finito il lavoro!!! ' set a connection string and connect to SAMPLE database ' using DB2 .NET Data Provider Dim connectionString = "Database=SAMPLE" Dim cnn As New DB2Connection(connectionString) cnn.Open() ' Use the connection in here… If cnn.State = ConnectionState.Open Then cnn.Close() End If © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

39 DB2Command Object Per comandi SQL statements o stored procedure
3/27/2017 2:28 AM DB2Command Object Per comandi SQL statements o stored procedure Command Object: ExecuteReader – ritorna un DataReader ExecuteNonQuery – non ritorna nulla ExecuteScalar – ritorna il primo valore scalare ' create a DB2Command with a SELECT statement Dim db2SelectCommand As New IBM.Data.DB2.DB2Command() db2SelectCommand.CommandText = "Select * from Customers" db2SelectCommand.Connection = myDB2Connection © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

40 DB2DataReader Object Cursore forward-only, read-only
3/27/2017 2:28 AM DB2DataReader Object Cursore forward-only, read-only Solo il record corrente in memoria ExecuteReader Chiudere per liberare la connessione Dim cnn As New DB2Connection(conDB2ConnectionString) Dim strSQL As String = "SELECT * FROM Department" Dim cmd As New DB2Command(strSQL, cnn) Dim dr As DB2DataReader cnn.Open() dr = cmd.ExecuteReader(CommandBehavior.CloseConnection) Do While dr.Read lstDept.Items.Add(String.Format("{0}: {1}, {2}", _ dr(“DEPTNO"), dr(“DEPTNAME"), dr(“MGRNO"))) Loop dr.Close() © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

41 Chiamare Stored Procedure
Attraverso l’oggetto Command Gestione dei parametri Dim dr As DB2DataReader Dim cnn As New DB2Connection(conDB2ConnectionString) Dim cmd As New DB2Command(“SomeSP", cnn) cnn.Open() cmd.CommandType = CommandType.StoredProcedure Dim prm As DB2Parameter = _ cmd.Parameters.Add(“SomeParam", “Foo") dr = cmd.ExecuteReader() While dr.Read lstDemo.Items.Add(String.Format( _ "{0}: {1}", dr(0), dr(1))) End While © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

42 3/27/2017 2:28 AM DB2DataAdapter Gestisce la sincronizzazione attraverso i 4 command object: SelectCommand UpdateCommand DeleteCommand InsertCommand Riempie un DataSet (metodo Fill) Aggiornamento dei dati in DB2 (metodo Update) © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

43 Add-in per Visual Studio.NET
3/27/2017 2:28 AM Add-in per Visual Studio.NET IBM Explorer IBM Projects (DB2 Database Project) DB2 SQL Editor DB2 .Net Data Provider tools Dynamic Help for DB2 Add-Ins DB2 Tools menu Add-in © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

44 IBM Explorer: Data Connection
3/27/2017 2:28 AM IBM Explorer: Data Connection Simile al Server Explorer per visualizzare gli oggetti in DB2 Browsing dei dati Drag and drop degli oggetti e generazione del codice © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

45 SQL Editor Estensione dell’editor di VS.Net per editare script DDL
3/27/2017 2:28 AM SQL Editor Estensione dell’editor di VS.Net per editare script DDL Supporto per : Sintassi colorata per DB2 SQL Intellisense e code completion Gestione dei code fragments per il codice DML utilizzato più di frequente © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

46 3/27/2017 2:28 AM Tools Add-in Toolbar per lanciare gli strumenti DB2 da Visual Studio.NET 2003 Development Center Control Center Replication Center Command Center Task Center Health Center Journal © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

47 Approfondimenti Download DB2 Personal Developer’s Edition (free)
3/27/2017 2:28 AM Approfondimenti Download DB2 Personal Developer’s Edition (free) Articoli e tutorial: IBM DB2 Development Add-Ins for Visual Studio .Net DB2 Database Project for Visual Studio .Net Creating a .NET Client that Uses DB2 DADX Web Services Creating and Linking LOBs in a Data Application for Microsoft .Net using DB2 Universal Database © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

48 Risorse Siti web Newsgroup IBM DB2 Developer Domain
3/27/2017 2:28 AM Risorse Siti web IBM DB2 Developer Domain DB2 for Windows home su developerWorks DB2 .NET home page Newsgroup comp.databases.ibm-db2 news://news.software.ibm.com/ibm.software.db2.udb.beta news://news.software.ibm.com/ibm.software.db2.udb © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.


Scaricare ppt "Oracle & SQL Server in a .NET World"

Presentazioni simili


Annunci Google