SlideShare ist ein Scribd-Unternehmen logo
1 von 21
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 ) ;
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-

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Kürzlich hochgeladen

Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 

Kürzlich hochgeladen (20)

Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 

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 ) ;
  • 14.
  • 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-