.NET Mobile Application Development Data in Distributed Systems Accessing Data with.NET.

Slides:



Advertisements
Similar presentations
17. Data Access ADO.Net Architecture New Features of ADO.NET
Advertisements

ADO vs ADO.NET ADOADO.NET Client/server coupledDisconnected collection of data from data server Uses RECORDSET object (contains one table) Uses DATASET.
By Chris Pascucci and FLF
Chapter 10 ADO. What is ADO? ADO is a Microsoft technology ADO stands for ActiveX Data Objects ADO is a programming interface to access data in a database.
Introduction to Database Processing with ADO.NET.
ADO. NET. What is “ADO.Net”? ADO.Net is a new object model for dealing with databases in.Net. Although some of the concepts are similar to the classical.
Chapter 12 Database Connectivity with ASP.NET JavaScript, Third Edition.
Programming in ADO.NET: Data-Centric Applications and ADO.NET Original copyright by Microsoft, 2002, with minor modifications by Dan Eaves, 2005.
Objective In this session we will discuss about : What is ADO. NET ?
Query Processing in Mobile Databases
Chapter 8 Binding Data to Web Controls. ASP.NET 2.0, Third Edition2.
ADO.NET – part II August 2004 [ Marmagna Desai]. CONTENTS ADO vs ADO.NET ADO.NET – Managed providers Connecting to Database SqlConnection Selecting Database.
ODBC, OLE DB, and ADO Introduction Dr. Ron Eaglin.
ADO.NET A2 Teacher Up skilling LECTURE 3. What’s to come today? ADO.NET What is ADO.NET? ADO.NET Objects SqlConnection SqlCommand SqlDataReader DataSet.
Overview of Data Access MacDonald Ch. 15 MIS 324 Professor Sandvig.
A Simple Introduction. What is ADO.net? First the word ADO stands for ActiveX Data Objects And it is an integral part of.Net Framework of Microsoft hence.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Needs for Accessing Database To make your web site more dynamic and maintainable, you can display information on your web pages that are retrieved from.
Databases and Data Access  Introduction to ADO.NET  ADO.NET objects  ADP.NET namespaces  Differences between ADO and ADO.NET.
.NET Data Access and Manipulation ADO.NET. Overview What is ADO.NET? Disconnected vs. connected data access models ADO.NET Architecture ADO.NET Core Objects.
1 Introduction to ADO.NET Microsoft ADO.NET 2.0 Step by Step Rebecca M Riordan Microsoft Press, 2006.
Database, SQL, and ADO.NET- Part 1 Session 11 Mata kuliah: M0874 – Programming II Tahun: 2010.
Overview – Chapter 11 SQL 710 Overview of Replication
Objectives In this lesson, you will learn to: *Identify the need for ADO.NET *Identify the features of ADO.NET *Identify the components of the ADO.NET.
ASP.NET Rina Zviel-Girshin Lecture 5
Module 9: Accessing Relational Data Using Microsoft Visual Studio.NET.
Session 8: ADO.NET. Overview Overview of ADO.NET What is ADO.NET? Using Namespaces The ADO.NET Object Model What is a DataSet? Accessing Data with ADO.NET.
Module 7: Accessing Data by Using ADO.NET
Christopher M. Pascucci.NET Programming: Databases & ADO.NET.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Introduction to ADO.NET ADO.NET - Lesson 01  Training time: 10 minutes  Author:
Object Oriented Software Development 10. Persistent Storage.
Presented by Joseph J. Sarna Jr. JJS Systems, LLC
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
An Introduction to ADO.Net Marmagna Desai.NET Seminar, Fall-2003.
 It is the primary data access model for.Net applications  Next version of ADO  Can be divided into two parts ◦ Providers ◦ DataSets  Resides in System.Data.
1 Data Classes- DataView DataGridView Control. Objectives 2  Data Class  DataAdapter  DataReader  DataSet  DataTable  DataView  DataGridView Control.
C# Programming in Depth Prof. Dr. Bertrand Meyer March 2007 – May 2007 Chair of Software Engineering Lecture 10: Database Lisa (Ling) Liu.
Database Farming For Improved Performance Presented By: Russell Yong Supervisor: Prof Wentworth.
Why ADO.NET Not your father’s Data Access.
SQL Server 2005 Implementation and Maintenance Chapter 12: Achieving High Availability Through Replication.
DEV383 The ADO.NET DataSet and You Jackie Goldstein General Manager Renaissance Computer Systems
ADO.NET AND STORED PROCEDURES - Swetha Kulkarni. RDBMS ADO.NET Provider  SqlClient  OracleClient  OleDb  ODBC  SqlServerCE System.Data.SqlClient.
Why ADO.NET Not your father’s Data Access.
Module 3: Working with Local Data. Overview Using DataSets Using XML Using SQL Server CE.
1 11/15/05CS360 Windows Programming ADO.NET Continued.
HNDIT Rapid Application Development
Database Connectivity with ASP.NET. 2 Introduction Web pages commonly used to: –Gather information stored on a Web server database Most server-side scripting.
ADO.NET FUNDAMENTALS BEGINNING ASP.NET 3.5 IN C#.
Module 4 Introduction ADO.NET.
Features Of SQL Server 2000: 1. Internet Integration: SQL Server 2000 works with other products to form a stable and secure data store for internet and.
C# .NET Software Development
Introduction Because database applications today reside in a complicated environment, various standards have been developed for accessing database servers.
Active Data Objects Using.Net ADO.Net Farooq Ahmed Amna Umber Summayya Shehzad.
Module 5 Data Classes DataView – DataGridView Control 1.
Module 2: Using ADO.NET to Access Data. Overview ADO.NET Architecture Creating an Application That Uses ADO.NET to Access Data Changing Database Records.
Data Access. ADO.NET ADO.NET is the primary library for building database solutions within the.NET Framework. ADO.NET does not replace ADO. ADO and OLEDB.
ADO .NET from. ADO .NET from “ADO .Net” Evolution/History of ADO.NET MICROSOFT .NET “ADO .Net” Evolution/History of ADO.NET History: Most applications.
.NET Data Access and Manipulation
DAT 390 Advanced ADO.NET Programming Techniques Jackie Goldstein Renaissance Computer Systems
Integrating Data Lesson 6.
Common SQL keywords. Building and using CASE Tools Data Base with Microsoft SQL-Server and C#
Data Access with ADO.NET
Introduction to ADO.NET
Introduction to Database Processing with ADO.NET
Introduction to Database Processing with ADO.NET
ADO.NET Framework.
Lecture 6 VB.Net SQL Server.
Chapter 10 ADO.
M S COLLEGE OF ART’S, COMM., SCI. & BMS Advance Web Programming
Introduction to Database Programming through ADO. NET
Presentation transcript:

.NET Mobile Application Development Data in Distributed Systems Accessing Data with.NET

Introduction  In this session we will consider >The use of databases in mobile and distributed applications >Connected, client-server database access ­.NET connected data access features >Disconnected database architecture ­ADO.NET and disconnected data access features >Distributed data access from mobile and disconnected clients ­SQL Server CE

Database Terminology  Relational database >data and relations between them organised in tables. A table is collection of rows or records. Each row in a table contains the same fields.tablesrecordsfields  Query >formal request to a database for information or updates to informationdatabase  Stored procedure >set of SQL commands that can be stored in the server >gives improved performance as less information needs to be sent between the server and the client  Structured Query Language (SQL) >industry-standard language for creating, updating and, querying relational databases

Databases in Distributed Systems  Distributed applications often rely on databases for >persistent storage >synchronizing state and ensuring consistency between multiple clients  Databases >normally reside on a server >accessed by clients via the network  Clients interact with databases using explicit SQL queries >active connection to database required for each query

Distributed Data Management  Three key aspects of managing data in distributed applications >Caching ­keeping local copies of required data eliminates need for continuous network connections >Replication ­propagating changes in cached data back to main data store ­periodically refreshing cached data >Conflict Resolution ­multiple clients operate simultaneously ­updates of a data item by several clients => conflict ­conflict resolution mechanisms needed

Database Access Methods  Traditional applications follow a layered model  Business logic/client layers interact with the database in a connected client/server manner >connection to database opened at start of session and maintained until session completes >SQL queries sent individually or in batches to database when required by application ­application cannot operate if network connection not present ­not ideally suited to mobile / intermittently connected clients Computer A Application front end Computer C Database Computer B Business Logic

Disconnected Database Access  In a disconnected data architecture client >opens temporary connection to database; required data cached locally and connection closed >operates using the cached data >reconnects to database when connection available and merges any changes from the locally cached data  Guaranteed network connection not required for application to function  Ideally suited to >mobile device applications >intermittently connected devices >clients with high network latencies (e.g. Internet)

.NET Data Access Features .NET supports >Connected and disconnected data architectures >Microsoft SQL Server data sources interaction from desktop and mobile platforms >Interaction with other database servers through ODBC and OLE from desktop platforms only .NET data access classes contained in >System.Data - Common data access types >System.Data.SqlClient - Types used for interacting with MS SQL Server >System.Data.Odbc - Types used for ODBC database interaction >System.Data.OleDb - Types used for OLE database interaction

.NET Connected Data Objects  Connection object (e.g. SqlConnection) >Represents connection to data source; used by other objects to interact with data source  Command object (e.g. OdbcCommand) >Represents queries to database or calls to stored procedures  DataReader object (e.g. OleDbDataReader) >Allows iteration through rows returned from a query  Transaction object (e.g. SqlTransaction) >Provides transactional support  Parameter object (e.g. SqlParameter) >Represents parameters to queries or stored procedures  DataAdapter object (e.g. SqlDataAdapter) >Bridge between database and the disconnected data objects of ADO.NET >Used in passing data between ADO.NET objects and data source

Connected Data Access Example using System.Data.SqlClient;... string connStr = "Initial Catalog=Northwind;Data Source=localhost;Integrated Security=SSPI;"; string insertQuery = "INSERT INTO Customers (CustomerID, CompanyName) Values('NWIND', 'Northwind Traders')"; SqlConnection conDB = new SqlConnection(connStr); SqlCommand cmd = new SqlCommand(insertQuery); cmd.Connection = conDB; conDB.Open(); cmd.ExecuteNonQuery(); conDB.Close();

ADO.NET Disconnected Data Objects  DataTable object >Stores data as collection of rows and columns  DataColumn object >Stores information about structure of a DataTable column  Constraint object >Enables constraints to be placed on data stored in a DataTable  DataRow object >Contains single record from a DataTable  DataSet object >Most important ADO.NET object >Container for multiple DataTables and DataRelations  DataRelation object >Defines relationships between DataTables in a DataSet  DataView object >Provides sorting and filtering of data in a DataSet >Enables binding of data to WinForms controls

Using ADO.NET Objects  ADO.NET objects can >be created and manipulated independently of a data source >be constructed to mirror the relational structure of a data source  Using a DataAdapter object, a DataSet can >be filled with data from a data source >merge changed values back in to a data source >become an offline cache of the data required by an application ­Allows application to operate even when network connection is not present

Disconnected Data Access Example using System.Data; using System.Data.SqlClient;... string connStr = "Initial Catalog=Northwind;Data Source=localhost; Integrated Security=SSPI;"; SqlConnection conDB = new SqlConnection(connStr); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = new SqlCommand("SELECT * FROM Suppliers", conDB); conDB.Open(); DataSet ds = new DataSet("Customers"); adapter.Fill(ds); conDB.Close(); string criteria = "Surname = Smith"; DataRow[] matchRows = ds.Tables["Customers"].Select(criteria); foreach (DataRow row in matchRows) { string forename = row["Forename"]; string forename = row["Surname"]; Console.WriteLine("Customer "+forename+" "+surname); }

Databases and Mobile Devices  All the preceding techniques can be used with mobile devices and Compact Framework  Mobile devices support three other techniques >SQL Server CE ­SQL Server database engine for WinCE devices >SQL Server CE Remote Data Access (RDA) ­enables two-way transfer of data between SQL CE database and networked SQL Server database >SQL Server Merge Replication ­more powerful mechanism for two-way data transfer between SQL CE database and networked SQL Server database with automatic conflict resolution

SQL Server CE  Lightweight version of MS SQL Server for Windows CE devices  Supports >creation, querying, updating and deleting of databases on device >useful for local caching of data from network databases to enable offline operation  Supports databases up to 2GB but size limited by available memory  Accessible from Compact Framework using classes in System.Data.SQlServerCe namespace >SqlCeEngine - used to creates new databases >SqlCeConnection >SqlCeCommand >SqlCeDataAdapter >SqlCeDataReader  Use is similar to standard SQL client

SqlCE Remote Data Access  Based around SqlCeRemoteDataAccess class  Two primary methods >Pull() ­retrieves data from networked SQL server and copies it to table in local SQL CE database ­pulled records not locked on networked database >Push() ­writes modifications back to networked SQL server based on data in local SQL CE database table ­overwrites changes made by other users to networked database (optimistic concurrency control) ­may result in lost updates  Networked SQL Server requires IIS Web server and specific configuration for RDA

SqlCe Merge Replication  Extension of SQL Server Merge Replication to mobile devices  Three databases used >Publisher - makes data available for replication >Distributor - manages replication and updates >Subscriber - receives/uses replicated data (on CE device)  Configurable resolvers used to automatically deal with multiple updates without loss of data  Merge replication vs Remote Data Access >requires much more configuration than RDA >much easier to use – automatically deals with conflicts

 In this session we have discussed >Databases in distributed applications >Connected database access with.NET >ADO.NET and the disconnected database architecture >Distributed data access from mobile and disconnected clients  The accompanying practical exercises demonstrate >Use of ADO.NET classes in manipulating data >Using ADO.NET to retrieve data from a networked database using Web services Summary

Reading and Resources Reading  Thomas Connolly & Carolyn Begg, Database Systems: A Practical Approach to Design, Implementation, and Management, Addison- Wesley, 2002  David Sceppa, Microsoft ADO.NET Core Reference, Microsoft Press, 2002  Andy Wigley & Stephen Wheelwright, Microsoft Compact Framework Core Reference, Microsoft Press, 2003 Chapters 13 – 17, pp 429 – 586 Resources  Microsoft Developer Network, SQL Server Documentation,