SlideShare a Scribd company logo
1 of 21
Download to read offline
ADO
ActiveX Data Object
ActiveX Data Object
• ADO is ActiveX Data Object that allows you to use data
from databases without knowing the implementation of
such a database.
• To access the data, programmer even don't have to
know SQL although there is a possibility of using SQL
commands through ADO as well.
• One of the main objects in ADO is a Recordset.
• The general idea of using ADO is the following:
– firstly you have to create and open a connection object that
allows you to connect to the database.
– Then you create a Recordset and retrieve data from the
database to it.
– Afterwards you have the possibility to save potential changes to
the database.
ActiveX Data Object
• ADO.NET is ActiveX Data Object for .NET and
it's a successor to ADO.NET although it was
changed completely.
• Its functionalities are similar to the ones from
ADO.
• It allows you to connect to data sources and
perform some operations on them.
• The main object in ADO.NET is Dataset, it's a
bit similar to Recordset but it provides more
possibilities for developers.
• ADO.NET makes possible disconnected
access to data by taking advantage of XML
files.
ActiveX Data Object
• ADO.NET provides also frameworks that make
using databases even simpler.
• ADO.NET Entity Framework for object-relational
mapping.
• It presents data from databases as objects and
thus makes it much easier to use it by rising
level of abstraction.
• Another framework that is very useful is LINQ
(Language Integrated Query), which allow you to
query data in a unified and clear way.
ADO and ADO.NET
• The ADO Recordset is now called the ADO.NET DataSet.
• ADO.NET uses disconnected models based on messages
whereas ADO is rather connection oriented.
• ADO.NET supports XML in an easy and clear way,
moreover it uses XML for passing data. On the other hand
standard ADO uses binary representation for passing
data.
• ADO is based on COM (Component Object Model) and
ADO.NET uses CLR (Common Language Runtime).
• Recordset in ADO and DataSet in ADO.NET.
• ADO.NET uses XML to communicate DataSets from point
to point.
• DataSets are a disconnected form of data access.
DataSet and Recordset
• Recordset represents data in memory, usually it's a table
or result of a query such as joining two tables or using
where clause.
• At one time there can be only one current record in
Recordset, if you want to perform operations on other
record you have to use move method.
• On the other hand DataSet can contain one or more tables
from database, these tables are stored in object called
DataTable.
• It is also very easy to retrieve data from it, you can use
simple foreach loop to do so.
• With DataSet you can also maintain relationships between
data tables such as for instance foreign key. Generally
DataSet can include more rich and complex data and
organize it in a clear manner.
DataSet and Recordset
• As I mentioned before ADO Recordset requires
constant connection to database to perform
some operations on it while ADO.NET DataSet
allows you to make changes and submit all of
them to the database later.
• ADO.NET uses also data adapter which
communicates with OLE DB provider while in
ADO you communicate with it directly.
• Data adapters are significant advantage
because it's very easy to set up and manage this
connection.
DataSet and Recordset
• performance of DataSets is better because of
its architecture, it's faster and more portable
than Recordset.
• DataSet stores data in XML so it's easier to
transfer it to other applications and they are
more firewall-prove than Recordsets that are
transferred using COM marshalling.
• DataSet is better and more robust tool to
manage data from databases and it provides
more functionalities.
DataSet
string source = “server=(local)” +“integrated
security=SSPI;” +“database=Northwind”;
SqlConnection conn = new SqlConnection(source);
conn.Open();

string query = "SELECT id, name FROM employees";
SqlDataAdapter adapter = new SqlDataAdapter(query, conn);

DataSet company = new DataSet();
adapter.Fill(company, "employees");
foreach (DataRow employee in company.Tables["employees"].Rows)

{
Console.WriteLine(employee["id"] + " " + employee["name"]);
}
Namespaces
• System.Data—All generic data access classes.
• System.Data.Common—Classes shared (or
overridden) by individual data providers.
• System.Data.Odbc—ODBC provider classes.
• System.Data.OleDb—OLE DB provider classes.
• System.Data.Oracle—Oracle provider classes.
• System.Data.SqlClient—SQLServer provider
classes.
• System.Data.SqlTypes—SQLServer data types.
classes are contained in the
System.Data
• DataSet—This object is designed for disconnected use
and can contain a set of DataTables and include
relationships between these tables.
• DataTable—A container of data that consists of one or
more DataColumns and, when populated, will have one
or more DataRows containing data.
• DataRow—A number of values, akin to a row from a
database table, or a row from a spreadsheet.
• DataColumn—This object contains the definition of a
column, such as the name and data type.
Database-Specific Classes
• SqlCommand, OleDbCommand, OracleCommand, and
ODBCComm and—Used as wrappers(binds) for SQL
statements or stored procedure calls.
• SqlConnection, OleDbConnection, OracleConnection,
ODBCConnection—Used to connect to the database.
Similar to an ADO Connection.
• SqlDataAdapter, OleDbDataAdapter,
OracleDataAdapter, ODBCDataAdapter—Used to hold
select, insert, update, and delete commands, which
are then used to populate a DataSet and update the
Database.
• SqlDataReader, OleDbDataReader, OracleDataReader,
ODBCDataReader —Used as a forward only,
connected data reader.
• dr = cmd.ExecuteReader();

while (dr.Read())
Executing Commands
• ExecuteNonQuery()—Executes the command
but does not return any output.
– SqlCommand cmd = new SqlCommand(select, conn);
– int rowsReturned = cmd.ExecuteNonQuery();
– Console.WriteLine(“{0} rows returned.”, rowsReturned);

• ExecuteReader()—Executes the command and
returns a typed DataReader.
–
–
–

dr = cmd.ExecuteReader();
while (dr.Read())
{
textBox1.Text = dr[0].ToString();

• ExecuteScalar()—Executes the command and
returns a single value.
– string select = “SELECT COUNT(*) FROM Customers”;
– object o = cmd.ExecuteScalar();
– Console.WriteLine ( o ) ;
Ado
Connecting to a User Instance
• The UserInstance and AttachDBFilenameConnectionS
tring keywords allow a SqlConnection to connect to a
user instance. User instances are also supported by
the SqlConnectionStringBuilderUserInstance and Attac
hDBFilename properties.
• Note the following about the sample connection string
shown below:
• The Data Source keyword refers to the parent instance
of SQL Server Express that is generating the user
instance. The default instance is .sqlexpress.
• Integrated Security is set to true. To
connect to a user instance, Windows
Authentication is required; SQL Server
logins are not supported.
• The User Instance is set to true, which
invokes a user instance.
• The AttachDbFileName connection string keyword is
used to attach the primary database file (.mdf), which
must include the full path
name. AttachDbFileName also corresponds to the
"extended properties" and "initial file name" keys within
a SqlConnection connection string.
• The |DataDirectory| substitution string enclosed in the
pipe symbols refers to the data directory of the
application opening the connection and provides a
relative path indicating the location of the .mdf and .ldf
database and log files. If you want to locate these files
elsewhere, you must provide the full path to the files.
The Security Support Provider
Interface

• To connect to the database server is recommended
to use Windows Authentication, commonly known as
integrated security. To specify the Windows
authentication, you can use any of the following two
key-value pairs with the data provider. NET
Framework for SQL Server:
• Integrated Security = true;
• Integrated Security = SSPI;
• However, only the second works with the data
provider. NET Framework OleDb. If you set
Integrated Security = true for ConnectionString an
exception is thrown.
• To specify the Windows authentication in
the data provider. NET Framework for
ODBC, you should use the following keyvalue pair.
• Trusted_Connection = yes;
• Let me start with Integrated Security =
false
• false User ID and Password are specified
in the connection string.
true Windows account credentials are
used for authentication.
• Recognized values are true, false, yes, no,
and SSPI.
• If User ID and Password are specified and
Integrated Security is set to true,
then User ID andPassword will be ignored
and Integrated Security will be used
SQL Server Express User
Instances
• Microsoft SQL Server Express Edition (SQL
Server Express) supports the user instance
feature, which is only available when using
the .NET Framework Data Provider for SQL
Server (SqlClient). A user instance is a
separate instance of the SQL Server Express
Database Engine that is generated by a parent
instance. User instances allow users who are
not administrators on their local computers to
attach and connect to SQL Server Express
databases. Each instance runs under the
security context of the individual user, on a one-

More Related Content

What's hot

Data Connection using ADO DC
Data Connection using ADO DCData Connection using ADO DC
Data Connection using ADO DCPurbanjali Das
 
05 SSIS Control Flow
05 SSIS Control Flow05 SSIS Control Flow
05 SSIS Control FlowSlava Kokaev
 
Fyp presentation 2 (SQL Converter)
Fyp presentation 2 (SQL Converter)Fyp presentation 2 (SQL Converter)
Fyp presentation 2 (SQL Converter)Muhammad Shafiq
 
Web Database
Web DatabaseWeb Database
Web Databaseidroos7
 
Chap 9 report (1st time upload/experiment)
Chap 9 report (1st time upload/experiment)Chap 9 report (1st time upload/experiment)
Chap 9 report (1st time upload/experiment)Ayitah Tallada
 
Object Relational Mapping with LINQ To SQL
Object Relational Mapping with LINQ To SQLObject Relational Mapping with LINQ To SQL
Object Relational Mapping with LINQ To SQLShahriar Hyder
 
Sql server 2012 dba online training
Sql server 2012 dba online trainingSql server 2012 dba online training
Sql server 2012 dba online trainingsqlmasters
 
SQL Server Integration Services – Enterprise Manageability
SQL Server Integration Services – Enterprise ManageabilitySQL Server Integration Services – Enterprise Manageability
SQL Server Integration Services – Enterprise ManageabilityDan English
 
SSIS Connection managers and data sources
SSIS Connection managers and data sourcesSSIS Connection managers and data sources
SSIS Connection managers and data sourcesSlava Kokaev
 
11g architecture
11g architecture11g architecture
11g architectureManohar Jha
 
Interoperability issues in accessing databases through Web Services
Interoperability issues in accessing databases through Web ServicesInteroperability issues in accessing databases through Web Services
Interoperability issues in accessing databases through Web Servicesinfopapers
 
Asp.net interview questions
Asp.net interview questionsAsp.net interview questions
Asp.net interview questionsAkhil Mittal
 
SSIS 2008 R2 data flow
SSIS 2008 R2 data flowSSIS 2008 R2 data flow
SSIS 2008 R2 data flowSlava Kokaev
 

What's hot (20)

Xml
XmlXml
Xml
 
Data Connection using ADO DC
Data Connection using ADO DCData Connection using ADO DC
Data Connection using ADO DC
 
05 SSIS Control Flow
05 SSIS Control Flow05 SSIS Control Flow
05 SSIS Control Flow
 
Fyp presentation 2 (SQL Converter)
Fyp presentation 2 (SQL Converter)Fyp presentation 2 (SQL Converter)
Fyp presentation 2 (SQL Converter)
 
Web Database
Web DatabaseWeb Database
Web Database
 
SSIS control flow
SSIS control flowSSIS control flow
SSIS control flow
 
Chap 9 report (1st time upload/experiment)
Chap 9 report (1st time upload/experiment)Chap 9 report (1st time upload/experiment)
Chap 9 report (1st time upload/experiment)
 
Object Relational Mapping with LINQ To SQL
Object Relational Mapping with LINQ To SQLObject Relational Mapping with LINQ To SQL
Object Relational Mapping with LINQ To SQL
 
SSIS Presentation
SSIS PresentationSSIS Presentation
SSIS Presentation
 
Sql server 2012 dba online training
Sql server 2012 dba online trainingSql server 2012 dba online training
Sql server 2012 dba online training
 
SQL Server Integration Services – Enterprise Manageability
SQL Server Integration Services – Enterprise ManageabilitySQL Server Integration Services – Enterprise Manageability
SQL Server Integration Services – Enterprise Manageability
 
Project seminar
Project seminarProject seminar
Project seminar
 
3. ADO.NET
3. ADO.NET3. ADO.NET
3. ADO.NET
 
SSIS Connection managers and data sources
SSIS Connection managers and data sourcesSSIS Connection managers and data sources
SSIS Connection managers and data sources
 
Power BI Interview Questions
Power BI Interview QuestionsPower BI Interview Questions
Power BI Interview Questions
 
11g architecture
11g architecture11g architecture
11g architecture
 
Interoperability issues in accessing databases through Web Services
Interoperability issues in accessing databases through Web ServicesInteroperability issues in accessing databases through Web Services
Interoperability issues in accessing databases through Web Services
 
Asp.net interview questions
Asp.net interview questionsAsp.net interview questions
Asp.net interview questions
 
Sql server basics
Sql server basicsSql server basics
Sql server basics
 
SSIS 2008 R2 data flow
SSIS 2008 R2 data flowSSIS 2008 R2 data flow
SSIS 2008 R2 data flow
 

Similar to Ado

Marmagna desai
Marmagna desaiMarmagna desai
Marmagna desaijmsthakur
 
Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.netNgeam Soly
 
Ado.Net Architecture
Ado.Net ArchitectureAdo.Net Architecture
Ado.Net ArchitectureUmar Farooq
 
Lecture 6. ADO.NET Overview.
Lecture 6. ADO.NET Overview.Lecture 6. ADO.NET Overview.
Lecture 6. ADO.NET Overview.Alexey Furmanov
 
LECTURE 14 Data Access.pptx
LECTURE 14 Data Access.pptxLECTURE 14 Data Access.pptx
LECTURE 14 Data Access.pptxAOmaAli
 
ASP.NET Session 11 12
ASP.NET Session 11 12ASP.NET Session 11 12
ASP.NET Session 11 12Sisir Ghosh
 
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentalsMadhuri Kavade
 
Introduction to ado
Introduction to adoIntroduction to ado
Introduction to adoHarman Bajwa
 
Introduction to ADO.NET
Introduction to ADO.NETIntroduction to ADO.NET
Introduction to ADO.NETrchakra
 
WEB PROGRAMMING USING ASP.NET
WEB PROGRAMMING USING ASP.NETWEB PROGRAMMING USING ASP.NET
WEB PROGRAMMING USING ASP.NETDhruvVekariya3
 
Asp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptxAsp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptxsridharu1981
 

Similar to Ado (20)

Marmagna desai
Marmagna desaiMarmagna desai
Marmagna desai
 
Ado .net
Ado .netAdo .net
Ado .net
 
Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.net
 
Ado.Net Architecture
Ado.Net ArchitectureAdo.Net Architecture
Ado.Net Architecture
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
Lecture 6. ADO.NET Overview.
Lecture 6. ADO.NET Overview.Lecture 6. ADO.NET Overview.
Lecture 6. ADO.NET Overview.
 
Ado.Net Tutorial
Ado.Net TutorialAdo.Net Tutorial
Ado.Net Tutorial
 
LECTURE 14 Data Access.pptx
LECTURE 14 Data Access.pptxLECTURE 14 Data Access.pptx
LECTURE 14 Data Access.pptx
 
ASP.NET Session 11 12
ASP.NET Session 11 12ASP.NET Session 11 12
ASP.NET Session 11 12
 
Ado.net
Ado.netAdo.net
Ado.net
 
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentals
 
Introduction to ado
Introduction to adoIntroduction to ado
Introduction to ado
 
Introduction to ADO.NET
Introduction to ADO.NETIntroduction to ADO.NET
Introduction to ADO.NET
 
WEB PROGRAMMING USING ASP.NET
WEB PROGRAMMING USING ASP.NETWEB PROGRAMMING USING ASP.NET
WEB PROGRAMMING USING ASP.NET
 
Ado.net
Ado.netAdo.net
Ado.net
 
Asp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptxAsp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptx
 
Ado
AdoAdo
Ado
 
ADO .Net
ADO .Net ADO .Net
ADO .Net
 
ADO.net control
ADO.net controlADO.net control
ADO.net control
 
ado.net
ado.netado.net
ado.net
 

More from abhay singh (14)

Iso 27001
Iso 27001Iso 27001
Iso 27001
 
Unsafe
UnsafeUnsafe
Unsafe
 
Threading
ThreadingThreading
Threading
 
Preprocessor
PreprocessorPreprocessor
Preprocessor
 
Networking and socket
Networking and socketNetworking and socket
Networking and socket
 
Namespace
NamespaceNamespace
Namespace
 
Inheritance
InheritanceInheritance
Inheritance
 
Generic
GenericGeneric
Generic
 
Gdi
GdiGdi
Gdi
 
Exception
ExceptionException
Exception
 
Delegate
DelegateDelegate
Delegate
 
Constructor
ConstructorConstructor
Constructor
 
Collection
CollectionCollection
Collection
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 

Recently uploaded

How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17Celine George
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.raviapr7
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxEduSkills OECD
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfMohonDas
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptxmary850239
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxraviapr7
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptxSandy Millin
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxAditiChauhan701637
 
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptxPractical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptxKatherine Villaluna
 
What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?TechSoup
 
M-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxM-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxDr. Santhosh Kumar. N
 
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdfMaximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdfTechSoup
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptxraviapr7
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...Nguyen Thanh Tu Collection
 
5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...CaraSkikne1
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxraviapr7
 
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRATanmoy Mishra
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxSaurabhParmar42
 

Recently uploaded (20)

How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdf
 
Finals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quizFinals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quiz
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptx
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptx
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptx
 
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptxPractical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptx
 
What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?
 
M-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxM-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptx
 
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdfMaximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
 
5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptx
 
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptx
 
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdfPersonal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
 

Ado

  • 2. ActiveX Data Object • ADO is ActiveX Data Object that allows you to use data from databases without knowing the implementation of such a database. • To access the data, programmer even don't have to know SQL although there is a possibility of using SQL commands through ADO as well. • One of the main objects in ADO is a Recordset. • The general idea of using ADO is the following: – firstly you have to create and open a connection object that allows you to connect to the database. – Then you create a Recordset and retrieve data from the database to it. – Afterwards you have the possibility to save potential changes to the database.
  • 3. ActiveX Data Object • ADO.NET is ActiveX Data Object for .NET and it's a successor to ADO.NET although it was changed completely. • Its functionalities are similar to the ones from ADO. • It allows you to connect to data sources and perform some operations on them. • The main object in ADO.NET is Dataset, it's a bit similar to Recordset but it provides more possibilities for developers. • ADO.NET makes possible disconnected access to data by taking advantage of XML files.
  • 4. ActiveX Data Object • ADO.NET provides also frameworks that make using databases even simpler. • ADO.NET Entity Framework for object-relational mapping. • It presents data from databases as objects and thus makes it much easier to use it by rising level of abstraction. • Another framework that is very useful is LINQ (Language Integrated Query), which allow you to query data in a unified and clear way.
  • 5. ADO and ADO.NET • The ADO Recordset is now called the ADO.NET DataSet. • ADO.NET uses disconnected models based on messages whereas ADO is rather connection oriented. • ADO.NET supports XML in an easy and clear way, moreover it uses XML for passing data. On the other hand standard ADO uses binary representation for passing data. • ADO is based on COM (Component Object Model) and ADO.NET uses CLR (Common Language Runtime). • Recordset in ADO and DataSet in ADO.NET. • ADO.NET uses XML to communicate DataSets from point to point. • DataSets are a disconnected form of data access.
  • 6. DataSet and Recordset • Recordset represents data in memory, usually it's a table or result of a query such as joining two tables or using where clause. • At one time there can be only one current record in Recordset, if you want to perform operations on other record you have to use move method. • On the other hand DataSet can contain one or more tables from database, these tables are stored in object called DataTable. • It is also very easy to retrieve data from it, you can use simple foreach loop to do so. • With DataSet you can also maintain relationships between data tables such as for instance foreign key. Generally DataSet can include more rich and complex data and organize it in a clear manner.
  • 7. DataSet and Recordset • As I mentioned before ADO Recordset requires constant connection to database to perform some operations on it while ADO.NET DataSet allows you to make changes and submit all of them to the database later. • ADO.NET uses also data adapter which communicates with OLE DB provider while in ADO you communicate with it directly. • Data adapters are significant advantage because it's very easy to set up and manage this connection.
  • 8. DataSet and Recordset • performance of DataSets is better because of its architecture, it's faster and more portable than Recordset. • DataSet stores data in XML so it's easier to transfer it to other applications and they are more firewall-prove than Recordsets that are transferred using COM marshalling. • DataSet is better and more robust tool to manage data from databases and it provides more functionalities.
  • 9. DataSet string source = “server=(local)” +“integrated security=SSPI;” +“database=Northwind”; SqlConnection conn = new SqlConnection(source); conn.Open(); string query = "SELECT id, name FROM employees"; SqlDataAdapter adapter = new SqlDataAdapter(query, conn); DataSet company = new DataSet(); adapter.Fill(company, "employees"); foreach (DataRow employee in company.Tables["employees"].Rows) { Console.WriteLine(employee["id"] + " " + employee["name"]); }
  • 10. Namespaces • System.Data—All generic data access classes. • System.Data.Common—Classes shared (or overridden) by individual data providers. • System.Data.Odbc—ODBC provider classes. • System.Data.OleDb—OLE DB provider classes. • System.Data.Oracle—Oracle provider classes. • System.Data.SqlClient—SQLServer provider classes. • System.Data.SqlTypes—SQLServer data types.
  • 11. classes are contained in the System.Data • DataSet—This object is designed for disconnected use and can contain a set of DataTables and include relationships between these tables. • DataTable—A container of data that consists of one or more DataColumns and, when populated, will have one or more DataRows containing data. • DataRow—A number of values, akin to a row from a database table, or a row from a spreadsheet. • DataColumn—This object contains the definition of a column, such as the name and data type.
  • 12. Database-Specific Classes • SqlCommand, OleDbCommand, OracleCommand, and ODBCComm and—Used as wrappers(binds) for SQL statements or stored procedure calls. • SqlConnection, OleDbConnection, OracleConnection, ODBCConnection—Used to connect to the database. Similar to an ADO Connection. • SqlDataAdapter, OleDbDataAdapter, OracleDataAdapter, ODBCDataAdapter—Used to hold select, insert, update, and delete commands, which are then used to populate a DataSet and update the Database. • SqlDataReader, OleDbDataReader, OracleDataReader, ODBCDataReader —Used as a forward only, connected data reader. • dr = cmd.ExecuteReader(); while (dr.Read())
  • 13. Executing Commands • ExecuteNonQuery()—Executes the command but does not return any output. – SqlCommand cmd = new SqlCommand(select, conn); – int rowsReturned = cmd.ExecuteNonQuery(); – Console.WriteLine(“{0} rows returned.”, rowsReturned); • ExecuteReader()—Executes the command and returns a typed DataReader. – – – dr = cmd.ExecuteReader(); while (dr.Read()) { textBox1.Text = dr[0].ToString(); • ExecuteScalar()—Executes the command and returns a single value. – string select = “SELECT COUNT(*) FROM Customers”; – object o = cmd.ExecuteScalar(); – Console.WriteLine ( o ) ;
  • 15. Connecting to a User Instance • The UserInstance and AttachDBFilenameConnectionS tring keywords allow a SqlConnection to connect to a user instance. User instances are also supported by the SqlConnectionStringBuilderUserInstance and Attac hDBFilename properties. • Note the following about the sample connection string shown below: • The Data Source keyword refers to the parent instance of SQL Server Express that is generating the user instance. The default instance is .sqlexpress.
  • 16. • Integrated Security is set to true. To connect to a user instance, Windows Authentication is required; SQL Server logins are not supported. • The User Instance is set to true, which invokes a user instance.
  • 17. • The AttachDbFileName connection string keyword is used to attach the primary database file (.mdf), which must include the full path name. AttachDbFileName also corresponds to the "extended properties" and "initial file name" keys within a SqlConnection connection string. • The |DataDirectory| substitution string enclosed in the pipe symbols refers to the data directory of the application opening the connection and provides a relative path indicating the location of the .mdf and .ldf database and log files. If you want to locate these files elsewhere, you must provide the full path to the files.
  • 18. The Security Support Provider Interface • To connect to the database server is recommended to use Windows Authentication, commonly known as integrated security. To specify the Windows authentication, you can use any of the following two key-value pairs with the data provider. NET Framework for SQL Server: • Integrated Security = true; • Integrated Security = SSPI; • However, only the second works with the data provider. NET Framework OleDb. If you set Integrated Security = true for ConnectionString an exception is thrown.
  • 19. • To specify the Windows authentication in the data provider. NET Framework for ODBC, you should use the following keyvalue pair. • Trusted_Connection = yes; • Let me start with Integrated Security = false • false User ID and Password are specified in the connection string. true Windows account credentials are used for authentication.
  • 20. • Recognized values are true, false, yes, no, and SSPI. • If User ID and Password are specified and Integrated Security is set to true, then User ID andPassword will be ignored and Integrated Security will be used
  • 21. SQL Server Express User Instances • Microsoft SQL Server Express Edition (SQL Server Express) supports the user instance feature, which is only available when using the .NET Framework Data Provider for SQL Server (SqlClient). A user instance is a separate instance of the SQL Server Express Database Engine that is generated by a parent instance. User instances allow users who are not administrators on their local computers to attach and connect to SQL Server Express databases. Each instance runs under the security context of the individual user, on a one-