SlideShare a Scribd company logo
DAO(Data Access Object)
DAO is familiar to database programmers using Microsoft Access Basic or
Microsoft Visual Basic. DAO uses the Microsoft Jet database engine (A database
engine is the software in a DBMS that parses and executes SQL statements and
accesses the physical data) to provide a set of data access objects: database
objects, tabledef and querydef objects, recordset objects, and others. DAO works
best with .mdb files like those created by Microsoft Access, but you can also
access ODBC data sources through DAO and the Microsoft Jet database engine.

Advantages of DAO
Easy to use.

Workspace level support. (A workspace is DAO's notion of a connection between
a user and a database. The workspace manages a list of databases that are active,
and of individual users or groups of users who are known to use the workspace. )

Both MFC and API provide DAO support.

Speed is relatively faster than ODBC for jet database engine databases.
Compatibility with the ODBC classes and with Microsoft Access Basic and
Microsoft Visual Basic.
Ability to specify relations between tables.
Databases You Can Access with DAO

    Databases using the Microsoft Jet database engine, created with Microsoft
     Access or Microsoft Visual Basic, versions 1.x, 2.x, and 3.0 of the database
     engine.
    Open Database Connectivity (ODBC) databases, including but not limited to
     Microsoft SQL Server, SYBASE SQL Server, and ORACLE Server. To access an
     ODBC database, you must have an appropriate ODBC driver for the
     database you want to access.
    Microsoft Excel, versions 3.0, 4.0, 5.0, and 7.0 worksheets.
    Text files.


                                                                                   1
ODBC

    The ODBC interface is an industry standard and a component of Microsoft
       Windows Open Services Architecture (WOSA). The ODBC interface makes it
       possible for applications to access data from a variety of database
       management systems (DBMSs). ODBC permits maximum interoperability
       (The ability of one application to use the same code when accessing data
       in different DBMSs) -an application can access data in diverse DBMSs
       through a single interface. Furthermore, that application will be
       independent of any DBMS from which it accesses data. Users of the
       application can add software components called drivers, which
       create an interface between an application and a specific DBMS.
    ODBC defines a standard set of functions for data access and carries a
     specification for which vendors can write drivers (A driver is a routine
     library that exposes the functions in the ODBC API. Drivers are specific to
     a single DBMS) that grant your application access to almost any of the
     databases currently available.
Data Source

The data source name represents a specific database or file that your ODBC application will
access. The database may be comprised of many different tables, and once you're connected to
the data source you can access any object within it.

          •   A data source is the data that the user wants to access and its associated
              operating system, DBMS, and network platform (if any).

A data source name really is just that: a name. When you ask the driver manager to connect
you to a data source, it looks up the rest of the information it needs to get from your program
on your machine to the data source, wherever and on whatever machine that information lives.

ODBC specifies that each driver must implement a standardized set of SQL queries.

ODBC also standardizes the API used to access the database, which means that the SQL
commands and the calls you use to express those commands are interpreted in a common style
by the driver.



                                                                                              2
Examples of data sources include a remote database running on Microsoft SQL Server across a
network or a Microsoft Access file in a local directory.

ODBC Layered Architecture

ODBC has a layered architecture. At the top, it starts with your application, which is written to
call the ODBC APIs. Your application requests that a data source be opened by specifying a data
source name configured by the user.




The data source name provides the next layer, the driver manager, with enough information to
do its work. The manager loads the appropriate ODBC driver and initializes it for a connection
to the data source you've named. The driver manager passes on any subsequent calls to the
ODBC API, from your application to the driver. The driver actually implements the call, doing
the work required to retrieve or accept data, or performing housekeeping chores.

Databases You Can Access with ODBC


                                                                                                3
Using ODBC and the MFC ODBC classes, you can access any data source, local or remote, for
which the user of your application has an ODBC driver. 16-bit, 32-bit, and 64-bit ODBC drivers
are available for a wide range of data sources. If you are working with a Microsoft Jet (.mdb)
database, it is more efficient to use the DAO classes than the Microsoft Access ODBC driver.

Advantages of ODBC

Easy to use specially when developer are not familiar with COM environment.

SQL support.

Both API and MFC support.

Good for relational databases only.

DAO (Data Access Object)

Data access objects are exactly what their name implies: a set of Automation objects that allow
your application to gain entry to different databases.

Using DAO to work with native Microsoft Access databases provides the best performance .

Creating Data Sources

When you start working with ODBC, you'll always get started by using a data source.

When you create a data source in your application, you're really only creating a link between
the actual data source and ODBC.

Steps for setting up a default data source using ODBC

   1. First step in creating an ODBC data source, as viewed through Control Panel, is to
      double-click on the ODBC icon. This will bring up the ODBC Data Source Administrator
      dialog box, as shown below:




                                                                                                 4
2. To create a new data source, just click the Add... Button ,Add Data Source Dialog Box will be
displayed. Choose Microsoft Access driver from the list of drivers displayed & click on OK.
ODBC Microsoft Set up Dialog box will appear which is shown below:




                                                                                                   5
3. Enter the data source name (that u’ve used in codes) and description and click on
      Select.

   4. In the Select database dialog box , from the list of databases select database you have
      created.

   5. Click on OK .you will return to previous dialog box of ODBC Microsoft Set up Dialog box
      .

6. The data source has been set .Click Ok.

Now ,you will see again the startup dialog box with your DSN . Click close to complete the
process.

Steps to create building a Database Application using ODBC using AppWizard

   1. Select File | New. This opens the New Wizard.

                                                                                                6
2. On the Projects tab, select MFC AppWizard (exe).

3. Type a name for your project, such as Hello, in the Project Name field.

4. Click OK. This causes the New Wizard to do two things: create a project directory (specified
in the Location field) and then start the AppWizard.




Steps to create application using AppWizard

   1. In Step 1 of the AppWizard, specify that whether you want to create a Dialog-based
      application , SDI or MDI application. Click Next at the bottom of the wizard.




                                                                                              7
2. In Step 2 of the AppWizard, the wizard asks you about a number of features that you
   can include in your application. Here we check the option for including support for
   database files in your application. Because we want to create any database application
   ,so check this box. Then we have to click on Data Source button to select data source
   which we have created.




                                                                                            8
3. In Step 3 of the AppWizard, the wizard asks you about a number of features that you
   can include in your application. You can uncheck the option for including support for
   ActiveX controls if you will not be using any ActiveX controls in your application.
   Because you won't be using any ActiveX controls in today's application, go ahead and
   uncheck this box.




                                                                                           9
4. In Step 4 of the AppWizard, the wizard asks you about a number of features that you
   can include in your application. You can check or uncheck the features which you do not
   want or want in your application. Click Next at the bottom of the wizard to proceed to
   the next AppWizard step.




                                                                                        10
5. In Step 5 of the AppWizard, leave the defaults for including source file comments and
   using the MFC library as a DLL. Click Next at the bottom of the wizard to proceed to the
   final AppWizard step.




                                                                                          11
6. The final step of the AppWizard shows you the C++ classes that the AppWizard will create for
your application. Click Finish to let AppWizard generate your application shell.

Before AppWizard creates your application shell, it presents you with a list of what it is going to
put into the application shell, based on the options you selected when going through the
AppWizard. Click OK and AppWizard generates your application.

DAO vs ODBC




                                                                                                 12
DAO                                     ODBC
1. Data Access Object                   Open Data Base Connectivity


2. DAO is an object-oriented            ODBC is a call-oriented API .
database programming model.


3. DAO allows you to open a        ODBC doesn’t.
database and directly perform data
definition language calls .


4. DAO enforces the notion of           When you use ODBC to connect to a
connecting to a database as an          database, you're connected direct
object. When you use DAO, you'll        to the database and you're ready to
ask it to get connected to the          work with its data.
database and use a workspace
object to manipulate the database
itself, i.e. the configuration of the
database and its tables, indexes
and other entities.


5. Speed is relatively faster than      Speed is slower
ODBC for jet database engine
databases.


6. DAO is best choice when you          ODBC is for various type of
have DAO components installed on        database which provides ODBC
your machine and you are using          drivers such as SQL Server, Oracle,
Microsoft's jet database engine         MS-Access. for connecting to
based databases such as MS-Access,      different databases no matter how
SQL Server, MS-Excel or Paradox.        big they are - from tiny text files to
                                        large databases.

                                                                             13
7. DAO can manipulate ODBC              ODBC can manipulate ODBC data
databases. But it is less efficient for bases much efficiently.
this task becoz it is best used with
.mdb database files.


8. DAO classes in MFC only two        ODBC classes in MFC only
classes CDaoDatabase and              represent two classes: CDatabase
CDaoRecordset .                       and CRecordset.


9. System implements DAO              System implements ODBC libraries
libraries as COM objects.             as a set of DLLs.


10. DAO best suited for application   If your application using other
that manipulate .mdb and other file   database now and will using other
formats are FoxPro and Excel. So      database in future then using ODBC
application that use Microsoft        is beneficial.
Access and always using it ,then
you use DAO.


11. DAO classes provide more          But in ODBC , many functions are
powerful set of methods that can      not defined in ODBC which are
use to manipulate database            defined in DAO .
without having to write a lot of
complicated code or SQL
statements.


13. DAO is only interested in         ODBC connects to a data source.
connecting to databases.




                                                                         14
14. A DAO program would have to                 The users of an ODBC program can
be written to be configurable                   get to the Control Panel and
before you could change the                     reconfigure their data source list to
database you were working with.                 point at a different database
                                                without any trouble at all. This fact
                                                makes ODBC somewhat more
                                                scaleable and far more manageable
                                                than DAO.


15. DAO is more efficient at                    ODBC is less efficient at accessing
accessing the native file formats it            that same data through the
supports than ODBC                              appropriate driver.
16. Under DAO, dynamic recordsets Under ODBC, snapshot recordsets
are the default.                  are the default .


17. DAO to be less efficient than               More efficient than DAO.
ODBC when trying to access a
remote server .




Similarities between DAO and ODBC

ODBC and DAO both can manipulate ODBC data sources. However, DAO is less efficient at this
task because it's best used with .mdb database files.

AppWizard can create a basic database application based on either the ODBC or DAO classes.
Which type of application you want to create depends, at least in some part, on the type of
databases with which you will be working.

ODBC and DAO both use objects of an MFC database class to provide a connection to the
database being accessed. In ODBC, this database class is called CDatabase, whereas in DAO, the
class is called CDaoDatabase. Although these classes have different names, the DAO database
class contains some members similar to those found in the ODBC class.


                                                                                              15
Similarities between DAO and ODBC

ODBC and DAO both use objects of a recordset class to hold the currently selected records from
the database. In ODBC, this recordset class is called CRecordset, whereas in DAO, the class is
called CDaoRecordset. Although these classes have different names, the DAO recordset class
contains not only almost the same members as the ODBC class but also a large set of additional
member functions.

ODBC and DAO use similar procedures for viewing the contents of a data source. That is, in both
cases, the application must create a database object, create a recordset object, and then call
member functions of the appropriate classes to manipulate the database.

Choosing Between MFC DAO and ODBC Classes




                                                                                            16
Can I                  With DAO classes?        With ODBC classes?


Access .MDB files      YES                      YES
Access ODBC data       YES                      YES
sources
Available for 16 Bit                            YES
Available for 32 Bit   YES                      YES
Available for 64 Bit                            YES
Database engine        Microsoft Jet database   Target DBMS
support                engine


DDL support            YES                      Only through direct
                                                ODBC calls


DML support            YES                      YES


Nature of the MFC      "Wrapper" of DAO core Simplified abstraction
implementation         functions             rather than a
                                             "wrapper" of the ODBC
                                             API


Optimal for            .mdb files (Microsoft    Any DBMS for which
                       Access)                  you have a driver,
                                                especially in
                                                client/server
                                                situations




                                                                      17

More Related Content

PPTX
Windows programming
PPT
Windows programming ppt
PPT
Vc++ 3
PPT
introduction to_mfc
PPT
VC++ Fundamentals
PDF
Visual programming lab
PPTX
Working with Multiple Application - R.D.Sivakumar
PPT
Chapter 14
Windows programming
Windows programming ppt
Vc++ 3
introduction to_mfc
VC++ Fundamentals
Visual programming lab
Working with Multiple Application - R.D.Sivakumar
Chapter 14

What's hot (20)

PPTX
Visual programming
PDF
Mfc programming tutorial automation step by-step
PPT
Vc++ 2
PPT
Vc++ 4(mdi)
PPT
VB.Net GUI Unit_01
DOCX
Vb.net class notes
PPTX
Chapter 1 — Introduction to Visual Basic 2010 Programming
PDF
Visual Basic IDE Introduction
PPT
visual basic for the beginner
PPT
Visual basic
PPTX
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
PPT
Introduction to vb.net
PPT
Meaning Of VB
PPS
Vb.net session 02
PPT
Visual basics
PPTX
Sdi & mdi
PPT
Developing Microsoft .NET Applications for Windows
PDF
Vb tutorial
PPTX
Visual Basic Controls ppt
Visual programming
Mfc programming tutorial automation step by-step
Vc++ 2
Vc++ 4(mdi)
VB.Net GUI Unit_01
Vb.net class notes
Chapter 1 — Introduction to Visual Basic 2010 Programming
Visual Basic IDE Introduction
visual basic for the beginner
Visual basic
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
Introduction to vb.net
Meaning Of VB
Vb.net session 02
Visual basics
Sdi & mdi
Developing Microsoft .NET Applications for Windows
Vb tutorial
Visual Basic Controls ppt
Ad

Viewers also liked (14)

DOC
Programming windows
DOCX
Nagaraj belur
PPT
Seminar 2 ppt
PPTX
Tool bar
PPTX
Presentation 20111102
PPT
Windows presentation foundation
PPTX
Advanced VB: Object Oriented Programming - DLLs
PPT
32 dynamic linking nd overlays
PDF
Demand for Off-Grid Solar Electricity: Experimental Evidence from Rwanda
PPT
Active x control
PPTX
Presentation1
PPSX
C# - Part 1
PDF
C++ & VISUAL C++
PPTX
Presentation Introduction to Windows
Programming windows
Nagaraj belur
Seminar 2 ppt
Tool bar
Presentation 20111102
Windows presentation foundation
Advanced VB: Object Oriented Programming - DLLs
32 dynamic linking nd overlays
Demand for Off-Grid Solar Electricity: Experimental Evidence from Rwanda
Active x control
Presentation1
C# - Part 1
C++ & VISUAL C++
Presentation Introduction to Windows
Ad

Similar to Window programming (20)

PPTX
Conectarea sgdb acces la un server oracle
PPT
Project Presentation
PPTX
1 introduction
DOC
Microsoft data access components
PPT
PPT
Jdbc
PPT
Final Database Connectivity in JAVA.ppt
PDF
Ibm db2 10.5 for linux, unix, and windows developing ado.net and ole db app...
DOCX
PPT
Basic Java Database Connectivity(JDBC)
PDF
Sybase sup hybrid_web_container_article_wp
PPT
Windows azure
PDF
Quiz application system project report..pdf
PDF
PPT
Introduction to ado.net
PPTX
Chapter2 j2ee
PDF
Visual Basic.Net & Ado.Net
Conectarea sgdb acces la un server oracle
Project Presentation
1 introduction
Microsoft data access components
Jdbc
Final Database Connectivity in JAVA.ppt
Ibm db2 10.5 for linux, unix, and windows developing ado.net and ole db app...
Basic Java Database Connectivity(JDBC)
Sybase sup hybrid_web_container_article_wp
Windows azure
Quiz application system project report..pdf
Introduction to ado.net
Chapter2 j2ee
Visual Basic.Net & Ado.Net

Window programming

  • 1. DAO(Data Access Object) DAO is familiar to database programmers using Microsoft Access Basic or Microsoft Visual Basic. DAO uses the Microsoft Jet database engine (A database engine is the software in a DBMS that parses and executes SQL statements and accesses the physical data) to provide a set of data access objects: database objects, tabledef and querydef objects, recordset objects, and others. DAO works best with .mdb files like those created by Microsoft Access, but you can also access ODBC data sources through DAO and the Microsoft Jet database engine. Advantages of DAO Easy to use. Workspace level support. (A workspace is DAO's notion of a connection between a user and a database. The workspace manages a list of databases that are active, and of individual users or groups of users who are known to use the workspace. ) Both MFC and API provide DAO support. Speed is relatively faster than ODBC for jet database engine databases. Compatibility with the ODBC classes and with Microsoft Access Basic and Microsoft Visual Basic. Ability to specify relations between tables. Databases You Can Access with DAO  Databases using the Microsoft Jet database engine, created with Microsoft Access or Microsoft Visual Basic, versions 1.x, 2.x, and 3.0 of the database engine.  Open Database Connectivity (ODBC) databases, including but not limited to Microsoft SQL Server, SYBASE SQL Server, and ORACLE Server. To access an ODBC database, you must have an appropriate ODBC driver for the database you want to access.  Microsoft Excel, versions 3.0, 4.0, 5.0, and 7.0 worksheets.  Text files. 1
  • 2. ODBC  The ODBC interface is an industry standard and a component of Microsoft Windows Open Services Architecture (WOSA). The ODBC interface makes it possible for applications to access data from a variety of database management systems (DBMSs). ODBC permits maximum interoperability (The ability of one application to use the same code when accessing data in different DBMSs) -an application can access data in diverse DBMSs through a single interface. Furthermore, that application will be independent of any DBMS from which it accesses data. Users of the application can add software components called drivers, which create an interface between an application and a specific DBMS.  ODBC defines a standard set of functions for data access and carries a specification for which vendors can write drivers (A driver is a routine library that exposes the functions in the ODBC API. Drivers are specific to a single DBMS) that grant your application access to almost any of the databases currently available. Data Source The data source name represents a specific database or file that your ODBC application will access. The database may be comprised of many different tables, and once you're connected to the data source you can access any object within it. • A data source is the data that the user wants to access and its associated operating system, DBMS, and network platform (if any). A data source name really is just that: a name. When you ask the driver manager to connect you to a data source, it looks up the rest of the information it needs to get from your program on your machine to the data source, wherever and on whatever machine that information lives. ODBC specifies that each driver must implement a standardized set of SQL queries. ODBC also standardizes the API used to access the database, which means that the SQL commands and the calls you use to express those commands are interpreted in a common style by the driver. 2
  • 3. Examples of data sources include a remote database running on Microsoft SQL Server across a network or a Microsoft Access file in a local directory. ODBC Layered Architecture ODBC has a layered architecture. At the top, it starts with your application, which is written to call the ODBC APIs. Your application requests that a data source be opened by specifying a data source name configured by the user. The data source name provides the next layer, the driver manager, with enough information to do its work. The manager loads the appropriate ODBC driver and initializes it for a connection to the data source you've named. The driver manager passes on any subsequent calls to the ODBC API, from your application to the driver. The driver actually implements the call, doing the work required to retrieve or accept data, or performing housekeeping chores. Databases You Can Access with ODBC 3
  • 4. Using ODBC and the MFC ODBC classes, you can access any data source, local or remote, for which the user of your application has an ODBC driver. 16-bit, 32-bit, and 64-bit ODBC drivers are available for a wide range of data sources. If you are working with a Microsoft Jet (.mdb) database, it is more efficient to use the DAO classes than the Microsoft Access ODBC driver. Advantages of ODBC Easy to use specially when developer are not familiar with COM environment. SQL support. Both API and MFC support. Good for relational databases only. DAO (Data Access Object) Data access objects are exactly what their name implies: a set of Automation objects that allow your application to gain entry to different databases. Using DAO to work with native Microsoft Access databases provides the best performance . Creating Data Sources When you start working with ODBC, you'll always get started by using a data source. When you create a data source in your application, you're really only creating a link between the actual data source and ODBC. Steps for setting up a default data source using ODBC 1. First step in creating an ODBC data source, as viewed through Control Panel, is to double-click on the ODBC icon. This will bring up the ODBC Data Source Administrator dialog box, as shown below: 4
  • 5. 2. To create a new data source, just click the Add... Button ,Add Data Source Dialog Box will be displayed. Choose Microsoft Access driver from the list of drivers displayed & click on OK. ODBC Microsoft Set up Dialog box will appear which is shown below: 5
  • 6. 3. Enter the data source name (that u’ve used in codes) and description and click on Select. 4. In the Select database dialog box , from the list of databases select database you have created. 5. Click on OK .you will return to previous dialog box of ODBC Microsoft Set up Dialog box . 6. The data source has been set .Click Ok. Now ,you will see again the startup dialog box with your DSN . Click close to complete the process. Steps to create building a Database Application using ODBC using AppWizard 1. Select File | New. This opens the New Wizard. 6
  • 7. 2. On the Projects tab, select MFC AppWizard (exe). 3. Type a name for your project, such as Hello, in the Project Name field. 4. Click OK. This causes the New Wizard to do two things: create a project directory (specified in the Location field) and then start the AppWizard. Steps to create application using AppWizard 1. In Step 1 of the AppWizard, specify that whether you want to create a Dialog-based application , SDI or MDI application. Click Next at the bottom of the wizard. 7
  • 8. 2. In Step 2 of the AppWizard, the wizard asks you about a number of features that you can include in your application. Here we check the option for including support for database files in your application. Because we want to create any database application ,so check this box. Then we have to click on Data Source button to select data source which we have created. 8
  • 9. 3. In Step 3 of the AppWizard, the wizard asks you about a number of features that you can include in your application. You can uncheck the option for including support for ActiveX controls if you will not be using any ActiveX controls in your application. Because you won't be using any ActiveX controls in today's application, go ahead and uncheck this box. 9
  • 10. 4. In Step 4 of the AppWizard, the wizard asks you about a number of features that you can include in your application. You can check or uncheck the features which you do not want or want in your application. Click Next at the bottom of the wizard to proceed to the next AppWizard step. 10
  • 11. 5. In Step 5 of the AppWizard, leave the defaults for including source file comments and using the MFC library as a DLL. Click Next at the bottom of the wizard to proceed to the final AppWizard step. 11
  • 12. 6. The final step of the AppWizard shows you the C++ classes that the AppWizard will create for your application. Click Finish to let AppWizard generate your application shell. Before AppWizard creates your application shell, it presents you with a list of what it is going to put into the application shell, based on the options you selected when going through the AppWizard. Click OK and AppWizard generates your application. DAO vs ODBC 12
  • 13. DAO ODBC 1. Data Access Object Open Data Base Connectivity 2. DAO is an object-oriented ODBC is a call-oriented API . database programming model. 3. DAO allows you to open a ODBC doesn’t. database and directly perform data definition language calls . 4. DAO enforces the notion of When you use ODBC to connect to a connecting to a database as an database, you're connected direct object. When you use DAO, you'll to the database and you're ready to ask it to get connected to the work with its data. database and use a workspace object to manipulate the database itself, i.e. the configuration of the database and its tables, indexes and other entities. 5. Speed is relatively faster than Speed is slower ODBC for jet database engine databases. 6. DAO is best choice when you ODBC is for various type of have DAO components installed on database which provides ODBC your machine and you are using drivers such as SQL Server, Oracle, Microsoft's jet database engine MS-Access. for connecting to based databases such as MS-Access, different databases no matter how SQL Server, MS-Excel or Paradox. big they are - from tiny text files to large databases. 13
  • 14. 7. DAO can manipulate ODBC ODBC can manipulate ODBC data databases. But it is less efficient for bases much efficiently. this task becoz it is best used with .mdb database files. 8. DAO classes in MFC only two ODBC classes in MFC only classes CDaoDatabase and represent two classes: CDatabase CDaoRecordset . and CRecordset. 9. System implements DAO System implements ODBC libraries libraries as COM objects. as a set of DLLs. 10. DAO best suited for application If your application using other that manipulate .mdb and other file database now and will using other formats are FoxPro and Excel. So database in future then using ODBC application that use Microsoft is beneficial. Access and always using it ,then you use DAO. 11. DAO classes provide more But in ODBC , many functions are powerful set of methods that can not defined in ODBC which are use to manipulate database defined in DAO . without having to write a lot of complicated code or SQL statements. 13. DAO is only interested in ODBC connects to a data source. connecting to databases. 14
  • 15. 14. A DAO program would have to The users of an ODBC program can be written to be configurable get to the Control Panel and before you could change the reconfigure their data source list to database you were working with. point at a different database without any trouble at all. This fact makes ODBC somewhat more scaleable and far more manageable than DAO. 15. DAO is more efficient at ODBC is less efficient at accessing accessing the native file formats it that same data through the supports than ODBC appropriate driver. 16. Under DAO, dynamic recordsets Under ODBC, snapshot recordsets are the default. are the default . 17. DAO to be less efficient than More efficient than DAO. ODBC when trying to access a remote server . Similarities between DAO and ODBC ODBC and DAO both can manipulate ODBC data sources. However, DAO is less efficient at this task because it's best used with .mdb database files. AppWizard can create a basic database application based on either the ODBC or DAO classes. Which type of application you want to create depends, at least in some part, on the type of databases with which you will be working. ODBC and DAO both use objects of an MFC database class to provide a connection to the database being accessed. In ODBC, this database class is called CDatabase, whereas in DAO, the class is called CDaoDatabase. Although these classes have different names, the DAO database class contains some members similar to those found in the ODBC class. 15
  • 16. Similarities between DAO and ODBC ODBC and DAO both use objects of a recordset class to hold the currently selected records from the database. In ODBC, this recordset class is called CRecordset, whereas in DAO, the class is called CDaoRecordset. Although these classes have different names, the DAO recordset class contains not only almost the same members as the ODBC class but also a large set of additional member functions. ODBC and DAO use similar procedures for viewing the contents of a data source. That is, in both cases, the application must create a database object, create a recordset object, and then call member functions of the appropriate classes to manipulate the database. Choosing Between MFC DAO and ODBC Classes 16
  • 17. Can I With DAO classes? With ODBC classes? Access .MDB files YES YES Access ODBC data YES YES sources Available for 16 Bit YES Available for 32 Bit YES YES Available for 64 Bit YES Database engine Microsoft Jet database Target DBMS support engine DDL support YES Only through direct ODBC calls DML support YES YES Nature of the MFC "Wrapper" of DAO core Simplified abstraction implementation functions rather than a "wrapper" of the ODBC API Optimal for .mdb files (Microsoft Any DBMS for which Access) you have a driver, especially in client/server situations 17