 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.

Slides:



Advertisements
Similar presentations
ADO.Net Modelo para acesso a dados nas aplicação.Net Componentes: DataSet.Net Data providers: Connection Command DataReader DataAdapter.
Advertisements

Database Connections with ASP.Net
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.
Introduction to Database Processing with ADO.NET.
VB.NET Database Access ISYS546. Microsoft Universal Data Access ODBC: Open Database Connectivity –A driver manager –Used for relational databases OLE.
Coding ADO.NET Objects: Connection, Command, DataReader.
1 ADO.NET. 2.NET Framework Data Namespaces System.Data –Base set of classes and interfaces for ADO.NET System.Data.Common –Classes shared by the.NET Data.
VB.NET Database Access ISYS 812. Microsoft Universal Data Access ODBC: Open Database Connectivity –A driver manager –Used for relational databases OLE.
1 Pertemuan 09 Database Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
VB.NET Database Access ISYS546. Microsoft Universal Data Access ODBC: Open Database Connectivity –A driver manager –Used for relational databases OLE.
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 ADO.NET Chapter 1 ADO.NET 4.0 Development.
In C# program Before you can start using the ODBC class definitions, you will need to include the right module. using System.Data.Odbc; // ODBC definitions.
From VS C# 2010 Programming, John Allwork 1 VS2010 C# Programming - DB intro 1 Topics – Database Relational - linked tables SQL ADO.NET objects Referencing.
Programming with Visual Basic.NET An Object-Oriented Approach  Chapter 8 Introduction to Database Processing.
ODBC, OLE DB, and ADO Introduction Dr. Ron Eaglin.
Chapter 61 Managing Data Sources Introduction to ASP.NET By Kathleen Kalata.
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.
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.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 30 – Bookstore Application: Client Tier Examining.
.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.
Chapter 3 Introduction to ADO.NET 3.1 The ADO and ADO.NET ActiveX Data Object (ADO) is developed based on Object Linking and Embedding (OLE) and Component.
Database, SQL, and ADO.NET- Part 1 Session 11 Mata kuliah: M0874 – Programming II Tahun: 2010.
10/26/20151 Chapter 3 Introduction to ADO.NET In this chapter, you will: Learn the basic classes in ADO.NET and its architecture Learn the different ADO.NET.
ASP.NET Rina Zviel-Girshin Lecture 5
Module 7: Accessing Data by Using ADO.NET
ADO.NET Data Access. Page  2 SQL  When we interact with the datasource through ADO.NET we use the SQL language to retrieve,modify,update information.
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:
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.
Module 3: Performing Connected Database Operations.
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.
1 11/10/05CS360 Windows Programming ADO.NET. 2 11/10/05CS360 Windows Programming ADO.NET  Behind every great application is a database manager o Amazon.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 25.1 Test-Driving the ATM Application 25.2.
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.
1 Database Programming with ADO.NET Kashef Mughal.
Active Data Objects Using.Net ADO.Net Farooq Ahmed Amna Umber Summayya Shehzad.
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
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
Common SQL keywords. Building and using CASE Tools Data Base with Microsoft SQL-Server and C#
ASP.NET Programming with C# and SQL Server First Edition
Data Access with ADO.NET
Introduction to Database Processing with ADO.NET
Introduction to Database Processing with ADO.NET
ADO.NET Framework.
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
Programming the Web Using ASP.Net
Lecture 6 VB.Net SQL Server.
Active Data Objects Binding ASP.NET Controls to Data
VB.NET Using Database.
Tonga Institute of Higher Education
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Chapter 10 ADO.
Introduction To Structured Query Language (SQL)
Chapter 10 Accessing Database Files
Active Data Objects Binding ASP.NET Controls to Data
Presentation transcript:

 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 namespace

 It enables connection to the data source  Each data source has it’s own connection provider  Common data access objects ◦ Connection ◦ Command ◦ Parameter ◦ DataAdapter ◦ DataReader

 It provides the connection that is used for accessing data source  Common types ◦ OleDbConnection ◦ OdbcConnection ◦ SqlConnection

 Object Linking and Embedding Database  It aims to access to specific set of data sources from.Net applications  Continuous access to data source even path of the source is changes.  Odbc vs OleDb  System.Data.OleDb

 Commonly used properties and functions ◦ ConnectionString ◦ ConnectionTimeout ◦ BeginTransaction() ◦ Close() ◦ CreateCommand() ◦ Open()

To add a connection object to the form, just drag and drop an OleDbConnection from the toolbox

 Use ConnectionString property in to Properties Window to set connection information.  DataLink properties window will be opened when you ConnectionString property click

 From the first tab select the type of data provider  To define a connection to an access database, you should select Microsoft Jet 4.0 OLE Db Provider

 It performs CRUD (Create-Read-Update- Delete) operations on the database.  Common Types ◦ OdbcCommand ◦ OleDbCommand ◦ SqlCommand

 It uses OleDb framework  Common properties and functions ◦ CommandText ◦ Connection ◦ Parameters ◦ Transaction ◦ ExecuteNonQuery() ◦ ExecuteReader()

 Constructors ◦ OleDbCommand() ◦ OleDbCommand(string cmdText) ◦ OleDbCommand(string cmdText, OleDbConnection myoledbConn) ◦ OleDbCommand(string cmdText, OleDbConnection myoledbConn, OleDbTransaction myoledbtrans)

Type of the object Name of the object Connection object The SQL command that will be run

 It provides a data parameter to command object  Usage; ◦ First crate a command object with an SQL statement which contains special characters for placing parameters. ◦ Add parameters to the command object with assigning values ◦ Execute the command object

Adding parameters Type of the parameter Length of the parameter Assigning values to the parameter

 Used for retrieving data from datasource without modifying the actual data (works readonly)  Common types ◦ OdbcDataReader ◦ OleDbDataReader ◦ SqlDataReader ◦ OracleDataReader ◦ Db2DataReader

 It has no public constructor. So, to crate a DataReader object you should call ExecuteReader() function of the releates command object. ◦ OleDbDataReader ordr = ocmd.ExecuteReader();  When Read() fucntion is called, DateReader object starts to read data or moves to next record. ◦ if(ordr.Read()) ◦ while(ordr.Read())  To access actual data one should use indexes or Get functions of the reader ◦ ordr[0].ToString(); ◦ ordr[“NameOfTheColumn”].ToString() ◦ ordr.GetString(0);

 If you plan to continue to use Connection object (e.g. to execute another SQL statement), then you should call Close() function of the reader object. ◦ ordr.Close();  Common properties and functions ◦ IsClosed ◦ FieldCount ◦ GetInt32(), GetDecimal(), GetString() ◦ IsDBNull() ◦ Read() ◦ Close

Reader object If there is data to be read Create reader object by executing the command Fetch the data by providing the column number on the current row

Reader object If there is data to be read Create reader object by executing the command Fetch the data by providing the column name on the current row

 Filter a set of data  Eleminates row mismathcing rows, passes matching ones.  If a select sql is executed without a where keyword, then all rows in tables that are used in select sql will be returned.  It needs columns in order to be used  Pay importance to data types while using where keyword.

 SELECT * FROM PERSONEL WHERE ADI = ‘ALİ’ ◦ This query will return all rows in table PERSONEL whose name are equal to ALİ ◦ where keyword should be used after table name ◦ After then we should write filter statements  SELECT * FROM PERSONEL WHERE ADI LIKE ‘AL%’ ◦ This query will return all rows in table PERSONEL whose name starts with AL ◦ LIKE keyword is used to search for specified patterns in a column.  SELECT * FROM PERSONEL WHERE ADI = ‘ALİ’ AND SOYADI = ‘KAYA’ ◦ Where keyword may include multiple filtering statements ◦ The sql query seen above will return the rows with name equals ALİ and surname equals KAYA

 It is used for erasing records from table  Generally used with where keyword  It is an irreversible operation (unless used within a transaction), so use it very carefully.  To execute a delete sql, first put it in to a command object, then call ExecuteNonQuery function.

 DELETE FROM PERSONEL ◦ Deletes all rows (records) in table PERSONEL  DELETE FROM PERSONEL WHERE AGE < 18 ◦ Deletes rows in table PERSONEL who are younger then 18  DELETE FROM PERSONEL WHERE ADI LIKE ‘AL%’ ◦ Deletes rows in table PERSONEL whose names starts with AL

 It is used for changing values in a tables  More effective then delete->insert  Usually used with where keyword  User should supply column names that will be updated  To execute a update sql, first put it in to a command object, then call ExecuteNonQuery function.

 UPDATE PERSONEL SET ADI = ‘ALİ’ ◦ Changes all names to ALİ in table PERSONEL  UPDATE PERSONEL SET YAS = 18 WHERE YAS < 18 AND SOYAD = ‘KAYA’ ◦ Sets the age value of the records to 18 who are younger than 18 and surname is KAYA

 This operation is called JOIN operation  It combines desired columns from multiple tables in to one data set.  Usually one column of a table is matched to anoter related column in other table  If two tables have column with same name, then we should write table names before column names to get over confusion

IDST_NAMEST_SURNAME 1ALİKAYA 2VELİTAN IDLC_NAME 5PHYSICS 6CHEMISTRY IDST_IDLC_IDGRADE STUDENTS LECTURES GRADES

 Id, name and surnames are stored in STUDENT table  Id and lecture names are stored in LECTURES table  In grades table we store the scores of students in courses  How to find the score of a student in a specified lecture.

 Answer: We have to combine (join) three tables.  How? ◦ Pick the id of the student from STUDENTS table ◦ Pick the lecture information from LECTURES table ◦ Pick the lectures that student attends from GRADES table ◦ Fetch grades of students from desired lessons from GRADES table

 Joining ◦ Join STUDENTS (ID) with GRADES(ST_ID) ◦ Join LECTURED(ID) with GRADES(LC_ID)

 To select student name, surname, attended lectures and grades we should write the following SQL query SELECT ST_NAME, ST_SURNAME, LC_NAME, GRADE FROM STUDENTS, GRADES, LECTURES WHERE STUDENTS.ID = GRADES.ST_ID AND LECTURES.ID = GRADES. LC_ID