4. Evolución del Acceso a Datos Evolución 1-Tier (monolithic) Client logic Business logic Data storage 3-Tier “ Thin” Client N-Tier 2-Tier “ Fat” Client Internet XML Web service
5.
6.
7.
8.
9.
10. Evolución del Acceso a Datos De ADO a ADO.NET ADO evoluciona en ADO.NET RecordSet DataReader DataAdapter DataSet Command Command Connection Connection
11. Evolución del Acceso a Datos Arquitectura de ADO.NET Business Tier Data Tier Presentation Tier Windows Forms Web Forms Business to Business Data Object (Class) DataSet DataSet DataSet Internet Intranet Data Adapter Data Adapter (BizTalk, for example) XML MyApp.Exe IE
12.
13. Evolución del Acceso a Datos Modelo de Objetos de ADO.NET DataSet SQL Server .NET Data Provider OLE DB .NET Data Provider SQL Server 7.0 (and later) OLEDB sources (SQL Server 6.5)
14.
15.
16.
17.
18.
19.
20.
21.
22. Objetos de ADO.NET El Objeto Connection //Specify the System.Data.SQL Namespace Using System.Data.SQL; // Create an instance of an SQLConnection object SQLConnection cnn = new SQLConnection(); // Set the connection string cnn.ConnectionString = "server=localhost;uid=sa;database=pubs"; //Open the Connection cnn.Open();
23.
24. Objetos de ADO.NET El Objeto Command // Create Command SQLCommand cmd = new SQLCommand(); // Set command's active connection and command text cmd.ActiveConnection = cnn; cmd.CommandText = "Select au_lname from authors where state = @param1"; // Create parameter and set value cmd.Parameters.Add( new SQLParameter("@param1", typeof(String),2) ); cmd.Parameters["@param1"].Value = "CA";
25.
26. Objetos de ADO.NET El Objeto DataReader // Define DataReader IDataReader dr; // Execute Command cmd.Execute(out dr); // Write out the results while(dr.Read()) { Console.WriteLine("Name = " + dr["au_lname"]); } // Close the connection cnn.Close();
27.
28.
29.
30. Manejo de DataSets Ciclo de Vida de un DataSet Original DataStore DataSet Table1 Table2 DataSet Table1 Table2 DataSet Table1 Table2 Establece las relaciones Hace los cambios a la data Resuelve los cambios con el proveedor manejado Extrae tablas Con Proveedor Manejado
31. Manejo de DataSets Ciclo de Vida de un DataSet DataSet Table1 Table2 DataSet Table1 Table2 DataSet Table1 Table2 Original DataStore Establece las relaciones Hace los cambios a la data Resuelve los cambios con el proveedor manejado Extrae tablas Con proveedore manejado Operaciones Conectadas
32. Manejo de DataSets Ciclo de Vida de un DataSet DataSet Table1 Table2 DataSet Table1 Table2 DataSet Table1 Table2 Original DataStore Establece las relaciones Hace los cambios a la data Resuelve los cambios con el proveedor manejado Extrae tablas Con proveedor manejado Operaciones Desconectadas
33. Manejo de DataSets Arquitectura del DataSet Employees Orders Customers Products Categories Categories Products SqlDataAdapter OleDbDataAdapter SQL Server 2000 Customers Orders SQL Server 6.5 DataSet XML Web service XmlDataDocument XML File
34. Manejo de DataSets Modelo de objetos del DataSet Servidor Fuente de Datos Database DataSet DataTable DataTable Connection Stored Procedure
35.
36.
37. Manejo de DataSets Ejemplo de DataSet // Create a "Pubs" DataSet DataSet pubs = new DataSet("Pubs"); //Create an "Inventory" Table DataTable inventory = new DataTable("Inventory"); inventory.Columns.Add("TitleID",typeof(Int32)); inventory.Columns.Add("Quantity",typeof(Int32)); // Add Inventory table to Pubs DataSet pubs.Tables.Add(inventory); // Add a record to the Inventory table DataRow row = inventory.NewRow(); row["TitleID"]=1; row["Quantity"]=25; inventory.Rows.Add(row);
38.
39. Manejo de DataSets El Objeto DataAdapter Data source DataAdapter DataTable DataTable DataSet DataAdapter Fill Update Fill Update
40. Manejo de DataSets El Objeto DataAdapter DataAdapter SelectCommand InsertCommand UpdateCommand DeleteCommand TableMappings Database DataSet
44. Manejo de DataSets El Objeto DataSet // Create a "Pubs" DataSet DataSet pubs = new DataSet("Pubs"); //Create an "Inventory" Table DataTable inventory = new DataTable("Inventory"); inventory.Columns.Add("TitleID",typeof(Int32)); inventory.Columns.Add("Quantity",typeof(Int32)); // Add Inventory table to Pubs DataSet pubs.Tables.Add(inventory); // Add a record to the Inventory table DataRow row = inventory.NewRow(); row["TitleID"]=1; row["Quantity"]=25; inventory.Rows.Add(row);
45.
46.
47.
48. Manejo de DataSets DataSets fuertemente Definidos Sintaxis como esta (similar a codigo ADO): Puede ser cambiada a sintaxix como esta: Ventajas – Más facil de leer, los errores de tipeo se capturan en tiempo de compilacion envez que en tiempo de ejecucion Dim rowCustomer As System.Data.DataRow For Each rowCustomer In MyDataSet.Tables("Customers").Rows Console.WriteLine(rowCustomer.Fields("CompanyName")) Next Dim rowCustomer As System.Data.DataRow For Each rowCustomer In MyDataSet.Customers.Rows Console.WriteLine(rowCustomer.CompanyName) Next
49.
50.
Hinweis der Redaktion
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components
What Is Microsoft ® .NET? Agenda: Day 1 Module 01: What is Microsoft ® .NET? Module 02: The .NET Framework Module 03: Visual Studio ® .NET Module 04: The .NET Languages Module 05 : Building ASP ® .NET Applications Module 06: Using Data Access in .NET Applications Module 07: Building Reusable Middle-Tier Components