It is the primary data access model for.net applications Next version of ADO Can be divided into two parts. Resides in System.

Similar documents
Data Access Standards. ODBC, OLE DB, and ADO Introduction. History of ODBC. History of ODBC 4/24/2016

ADO.NET.NET Data Access and Manipulation Mechanism. Nikita Gandotra Assistant Professor, Department of Computer Science & IT

A201 Object Oriented Programming with Visual Basic.Net

An Introduction to ADO.Net

BUILDING APPLICATIONS USING C# AND.NET FRAMEWORK (OBJECT-ORIENTED PROGRAMMING, X428.6)

ADO.NET for Beginners

PLATFORM TECHNOLOGY UNIT-4

Introducing.NET Data Management

iseries Access in the.net World

B Nagaraju

LẬP TRÌNH TRÊN MÔI TRƯỜNG WINDOWS *** ADO.NET

Create a Windows Application that Reads- Writes PI Data via PI OLEDB. Page 1

ADO.NET Overview. Connected Architecture. SqlConnection, SqlCommand, DataReader class. Disconnected Architecture

Contents. Chapter 1 Introducing ADO.NET...1. Acknowledgments...xiii. About the Authors...xv. Introduction...xix

EVALUATION COPY. Unauthorized reproduction or distribution is prohibited. Table of Contents (Detailed)

Data Access. Outline. Relational Databases ADO.NET Overview ADO.NET Classes 5/29/2013

Industrial Programming

A Programmer s Guide to ADO.NET in C# MAHESH CHAND

Mobile MOUSe ADO.NET FOR DEVELOPERS PART 1 ONLINE COURSE OUTLINE

.NET Connector. (MS Windows)

Lecture 10: Database. Lisa (Ling) Liu

.NET and DB2 united with IBM DB2.NET Data Provider Objectives :.NET ADO.NET DB2 and ADO.NET DB2 - ADO.NET applications

Data Source. Application. Memory

overview of, ASPNET User, Auto mode, 348 AutoIncrement property, 202 AutoNumber fields, 100 AVG function, 71

.NET data providers 5.1 WHAT IS A DATA PROVIDER?

Building Datacentric Applications

ADO.NET from 3,048 meters

Visual Basic.NET Complete Sybex, Inc.

Accessing Databases 7/6/2017 EC512 1

LẬP TRÌNH TRÊN MÔI TRƯỜNG WINDOWS ADO.NET

ADO.NET in Visual Basic

About the Authors Introduction p. 1 Exploring Application Architectures p. 9 Introduction p. 9 Choosing the "Right" Architecture p.

6.1 Understand Relational Database Management Systems

AUTHENTICATED WEB MANAGEMENT SYSTEM

BIS4430 Web-based Information Systems Management. Unit 11 [BIS4430, LU11 version1.0, E.M, 09/07)]

Oracle Rdb Technical Forums

CMPT 354 Database Systems I

ADO.NET. Two Providers ADO.NET. Namespace. Providers. Behind every great application is a database manager

6 Microsoft.Data.Odbc

Hands-On Lab. Introduction to SQL Azure. Lab version: Last updated: 12/15/2010

Mobile MOUSe ASP.NET FOR DEVELOPERS PART 1 ONLINE COURSE OUTLINE

Want to read more? Buy 2 books, get the 3rd FREE! Use discount code: OPC10 All orders over $29.95 qualify for free shipping within the US.

Hands-On Lab. Introduction to SQL Azure. Lab version: Last updated: 11/16/2010

Building Database Applications with ADO.NET

Reading From Databases

Advanced Programming C# Lecture 5. dr inż. Małgorzata Janik

Wildermuth_Index.qxd 10/9/02 3:22 PM Page 347 { Kirby Mountain Composition & Graphics } Index

Index. Numbers 1:1 (one-to-one) cardinality ratio, 29 1NF (first normal form), 33 2NF (second normal form), NF (third normal form), 34

ADO.NET Using Visual Basic 2005 Table of Contents

Using SQL Server 2OOO and ADO/ASP.NET in Database Instruction

VS2010 C# Programming - DB intro 1

Philadelphia University Faculty of Engineering

2.1 Read and Write XML Data. 2.2 Distinguish Between DataSet and DataReader Objects. 2.3 Call a Service from a Web Page

> ADO.NET: ActiveX Data Objects for.net, set of components used to interact with any DB/ XML docs

CHAPTER 1 INTRODUCING ADO.NET

Special Characters Numbers 467

5132_index Page 503 Thursday, April 25, :08 PM. Index

UNIT III APPLICATION DEVELOPMENT ON.NET

Connection Example. Document ID : Connection_Example.PDF Author : Michele Harris Version : 1.1 Date :

Programming with ADO.NET

ComponentOne. DataObjects for.net

Linking Reports to your Database in Crystal Reports 2008

Mainly three tables namely Teacher, Student and Class for small database of a school. are used. The snapshots of all three tables are shown below.

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 14 Database Connectivity and Web Technologies

TABLE OF CONTENTS. Data binding Datagrid 10 ComboBox 10 DropdownList 10. Special functions LoadFromSql* 11 FromXml/ToXml 12

III BSc(Information Technology)[ ] Batch Semester VI CORE: FRAMEWORK TECHNOLOGY-612B Multiple Choice Questions.

LABORATORY OF DATA SCIENCE. Data Access: Relational Data Bases. Data Science and Business Informatics Degree

Index. Symbols. ABS (Absolute) mathematical function, 295 Absolute function listing (10.1), 295

Chapter 3. Windows Database Applications The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill

III BCA 'A' and 'B' [ ] Semester VI Core: WEB TECHNOLOGY - 606B Multiple Choice Questions.

Copy Datatable Schema To Another Datatable Vb.net

19.5 ADO.NET Object Models

Program Contents: DOTNET TRAINING IN CHENNAI

UNIT - III BUILDING WINDOWS APPLICATION GENERAL WINDOWS CONTROLS FOR THE WINDOWS APPLICATION

TABLE OF CONTENTS. Data binding Datagrid 10 ComboBox 10 DropdownList 10

The Efficient Search Technique for Mechanical Component Selection

Volume CREATIVE DATA TECHNOLOGIES, INC. DATALAYER.NET. Getting Started Guide

B. V. Patel Institute of Business Management, Computer and Information Technology

C# Programming: From Problem Analysis to Program Design 2nd Edition. David McDonald, Ph.D. Director of Emerging Technologies. Objectives (1 of 2)

NAVIGATING TECHNOLOGY CHOICES FOR SAS DATA ACCESS FROM MULTI-TIERED WEB APPLICATIONS

Practical Database Programming with Visual Basic.NET

Mastering VB.NET using Visual Studio 2010 Course Length: 5 days Price: $2,500

2017/ st Sec Final revision Final revision

Windows Database Applications

Should read: Model First Reads: AutoIncementStep and AutoIncrementSeed

Integration Services. Creating an ETL Solution with SSIS. Module Overview. Introduction to ETL with SSIS Implementing Data Flow

CHOICE BASED CREDIT SYSTEM STRUCTURE. M.Sc COMPUTER SCIENCE

Crystal Reports. Overview. Contents. Differences between the Database menu in Crystal Reports 8.5 and 9

Form Adapter Example. DRAFT Document ID : Form_Adapter.PDF Author : Michele Harris Version : 1.1 Date :

Integrating External Assessments into a Blaise Questionnaire

Disconnected Data Access

ADO.NET 2.0. database programming with

ASP.NET Web Forms Programming Using Visual Basic.NET

Oracle Data Provider for.net

C# is intended to be a simple, modern, general-purpose, objectoriented programming language. Its development team is led by Anders Hejlsberg.

Chapter 8. ADO.NET Data Containers... 1 Data Adapters... 1 In-Memory Data Container Objects Conclusion... 35

Building Windows Front Ends to SAS Software. Katie Essam Amadeus Software Limited 20 th May 2003

2310C VB - Developing Web Applications Using Microsoft Visual Studio 2008 Course Number: 2310C Course Length: 5 Days

PREPARATION. Install MyGeneration and add the doodads project to your solution

Oracle Data Provider for.net

Transcription:

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 Connection object Name of the 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

It is a kind of bridge between data source and DataTable object Constructors OleDbDataAdapter() OleDbDataAdapter(OleDbCommand mycmd) OleDbDataAdapter(string cmdstring, OleDbConnection mysqlconn) OleDbDataAdapter(string cmdstring, string conn)

Common properties and funtions Fill() Update()

Create adapter object Create DataSet object Transfer data from DB to DataSet object Connection object

DataSet object used as a simple relational inmemory database in C# programs It uses DataAdapter object to access and modify data source Internal structures within a DataSet object DataSet DataTable DataColumn DataRow

Hierarchically defined DateSet objects

DataSet object represents the whole DB It includes tables and the relations between tables It is filled by calling Fill() function of the DataAdapter object. Common properties and functions Tables AcceptChanges() Clear()

Constructors DataSet() DataSet(string datasetnamestring) Example DataSet mydataset = new DataSet(); DataSet mydataset = new DataSet("myDataSet"); Type of the DataSet object Name of the DataSet object Create a new DataSet object

It resides in DataSet object It has name, columns and rows Instead of creating a new DataTable, we usually use the one that is inside a DataSet object A DataSet object may have more than one (multiple) DataTable objects.

DataColumn: It corresponds to a column in a DB table. It holds name and data type information. DataRow: It corresponds to a row in a DB table. It holds actual data and used in select, update, insert and delete operations.

Command DataSet object DataAdapter object Fill DataSet From first row of first table of DataAdapter Fetch data using column numbers

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 Sets the age value of the records to 18 who are younger than 18

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

STUDENTS ID ST_NAME ST_SURNAME 1 ALİ KAYA 2 VELİ TAN LECTURES ID LC_NAME 5 PHYSICS 6 CHEMISTRY GRADES ID ST_ID LC_ID GRADE 1 1 5 50 2 1 6 30 3 2 5 80

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