Introduction to Database Processing with ADO.NET.

Slides:



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

ADO.NET: Working in Disconnected Environment Sergey Baidachni MCT, MCSD, MCDBA.
Direct Data Access, Data Binding. Content Direct Data Access Data Binding Muzaffer DOĞAN - Anadolu University2.
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.
VB.NET Database Access ISYS546. Microsoft Universal Data Access ODBC: Open Database Connectivity –A driver manager –Used for relational databases OLE.
VB.NET Database Tools ISYS Net Applications OLE DB Provider OLE DB Data Source OLE DB Provider ODBC Data Source SQL Server Data Source SQL Server.Net.
VB.NET Database Access ISYS 812. Microsoft Universal Data Access ODBC: Open Database Connectivity –A driver manager –Used for relational databases OLE.
Introduction to ADO.Net, VB.Net Database Tools and Data Binding ISYS 512.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Chapter 12 Database Connectivity with ASP.NET JavaScript, Third Edition.
Objective In this session we will discuss about : What is ADO. NET ?
Overview of Database Access in.Net Josh Bowen CIS 764-FS2008.
C# programming with database Basic guideline. First step Install SQL Server 2008/2010 (Professional edition if possible) Install Visual Studio 2008/2010.
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.
Programming with Visual Basic.NET An Object-Oriented Approach  Chapter 8 Introduction to Database Processing.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 512.
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.
1 ASP.NET ASP.NET Rina Zviel-Girshin Lecture 4. 2 Overview Data Binding Data Providers Data Connection Data Manipulations.
CIS 451: Using ASP.NET Objects with SQL Dr. Ralph D. Westfall February, 2009.
Developing Web Applications Using Microsoft ® Visual Studio ® 2008.
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.
 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.
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:
ADO.NET Part 2. Slide 2 Overview Slide 3 Introduction to the DataGridView Control It’s a two-dimensional grid containing rows and columns Its use in.
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.
ADO.NET Objects – Data Providers Dr. Ron Eaglin. Requirements Visual Studio 2005 Microsoft SQL Server 2000 or 2005 –Adventure Works Database Installed.
 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.
Introduction to ADO.Net and VS Database Tools and Data Binding ISYS 350.
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.
Active Data Objects Using.Net ADO.Net Farooq Ahmed Amna Umber Summayya Shehzad.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 350.
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
Working with Data Lesson 4. Objectives DataSource Controls A requirement for most modern Web sites is that they be dynamic. –Static pages are not often.
 ADO.NET is an object-oriented set of libraries that allows you to interact with data sources  Commonly, the data source is a database, but it could.
ASP.NET Programming with C# and SQL Server First Edition
Introduction to ADO.NET
Introduction to Database Processing with ADO.NET
Introduction to Database Processing with ADO.NET
ADO.NET Framework.
Programming the Web Using ASP.Net
Lecture 6 VB.Net SQL Server.
Active Data Objects Binding ASP.NET Controls to Data
ADO.NET Accessing Databases in VS.NET
VB.NET Using Database.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Chapter 10 ADO.
Active Data Objects Binding ASP.NET Controls to Data
M S COLLEGE OF ART’S, COMM., SCI. & BMS Advance Web Programming
Introduction to Database Programming through ADO. NET
Introduction to ADO.Net and Visual Studio Database Tools.
Presentation transcript:

Introduction to Database Processing with ADO.NET

Slide 2 The ASP.NET / ADO.NET Conundrum The tools and wizards are wonderful for simple applications As applications become more complex and “real” You need to write code between the controls and the data providers Nested controls and one-to-many views become complex At some point, the visual designers become useless

Slide 3 Lecture Overview Introduce ASP.NET data sources Introduce the ASP.NET data bound controls Show a few SIMPLE examples to get us started

Slide 4 History of ADO (1) Open Database Connectivity (ODBC) was created to provide a uniform API to access SQL database servers OLE DB evolved from ODBC and provided a COM based interface Next came the first versions of ADO, which encapsulated OLE DB ADO.NET is the current generation of ADO and uses.NET Managed Providers

Slide 5 History of ADO (2) While not a problem Microsoft has stepped away from all MSAccess support. The data controls are gone Necessary Jet versions are not usually installed

Slide 6 ADO / ASP.NET NOTE The capabilities of ASP and ADO are vast There are many ways to accomplish the same task DataReaders vs. DataAdapters DataSource controls vs. manual binding Bound control configuration is sophisticated

Slide 7 ADO.NET -The Role of Managed Providers Managed providers interact with a data source and return data to an application Data sources are typically (almost always) disconnected After data is returned to the application, connections are closed

Slide 8 ADO.NET Namespaces / Classes (Intro) There are many of these Some you don’t need to work with directly There are many ways to accomplish the same task Mastery of the topic requires that you understand what the controls do and how they interact with the underlying classes

Slide 9 ADO.NET Namespaces (1) Here’s the fabric System.Data System.Data.SqlClient System.Data.OleDb System.Data.SqlTypes

Slide 10 ADO.NET Classes (1) Connection – creates the connection with the data source (database) Support is provided for ORACLE, SQL Server, Access, etc. Transaction – allows for transactional processing Command – typically an SQL statement executed against a database server Parameter – a parameter passed to a command

Slide 11 ADO.NET Classes (2) DataAdapter – a database object that returns a disconnected set of records ( DataSet and DataTable ) DataReader – a forward-only reader to get database records

Slide 12 Introduction to Connections Executing a database command is generally a two- step process Create a connection Prepare and execute a command The ASP.NET controls help automate much of the process There are specific connection classes for OLE DB, SQL Server and others They all work the same way

Slide 13 Connection Strings There are tools to build these for you based on the database provider Connection strings are typically stored in the web.config file They store all information needed to establish a database connection More later

Slide 14 Connection Strings (Example) Connection strings are usually stored in web.config The following reads the connection string from web.config

Slide 15 Connection Strings (Example) The SqlConnection object represents the connection itself. It’s properties depict the connection status

Slide 16 Executing Commands (Introduction) Use the SqlCommand object to Return one record one field ( ExecuteNonQuery ) Execute SQL INSERT, UPDATE, DELETE statements Return records in the form of a DataTable Return records one row at a time ( DataReader )

Slide 17 SqlCommand Object (Using 1 row) The OleDbCommand or SqlCommand objects work the same way Set the CommandText property to the SQL statement to execute Set the CommandType property to CommandType.Text Set the Connection property to an existing Connection object

Slide 18 SqlCommand Object (Using 1 row) To return one field from one row, call ExecutScalar() on the SqlCommand object

Slide 19 SqlCommand Object (Returning Nothing) Use the ExecuteNonQuery method to execute SQL statements that do not return values INSERT / UPDATE / DELETE As before, the CommandText property stores the SQL statement Two ways to do INSERT / UPDATE /DELETE With parameters Roll the statement by hand

Slide 20 SqlCommand Object (Returning Nothing - Manual) Use create the CommandText, CommandType and Connection as before The INSERT / UPDATE / DELETE statements get contorted

Slide 21 SqlCommand Object (Parameters 1 ) Parameters provide the preferred way to pass data to INSERT / UPDATE / DELETE and other SQL statements Parameters begin with in the SQL statement

Slide 22 SqlCommand Object (Parameters 1 ) Then we create the parameters as part of the command object We are adding items to the parameters collection

Slide 23 Using the DataReader This is straight out of the book There are much better ways to read data but here is the first cut It’s a forward only reader Call Read to read the first and subsequent records Create an SqlCommand object as before Call ExecuteReader to initialize Call Read to read each record Index contains the field name

Slide 24 Using the DataReader (example)

Slide 25 Reading Multiple Records Here, we use the DataSet and DataTable objects along with the DataAdapter Steps Create SqlCommand with the SELECT statement as before Create a new SqlDataAdapter Create a DataSet Call Fill on the DataAdapter to populate the DataSet

Slide 26 Reading Multiple Records

Slide 27 Introduction to Data Sources Data sources establish the connection between an ASP.NET application and a database These are not the same controls as the desktop controls

Slide 28 Data Source Controls (Categories) Tabular AccessDataSource – For Access databases SqlDataSource – For SQL databases ObjectDataSource – For custom business objects Hierarchical SiteMapDataSource – For menus XmlDataSource – To bind XML documents

Slide 29 Data Sources (Core Concepts) The ASP.NET data source controls are bound to a page rather than the application They belong to System.Web rather than System.Data so they are again unique to ASP.NET Underneath the hood, there is a DataSet You can use the System.Data classes from an ASP.NET application Visual Studio does a great job configuring the data source controls

Slide 30 Data Sources (Under the Hood 1) The Wizards configure properties to Write SELECT statements and customize them Write INSERT, UPDATE, and DELETE statements that are executed by other bound controls

Slide 31 Data Sources (Under the Hood 2) The Properties window tells the tale