?
Solved

Using CDaoDatabase class... includes, etc.

Posted on 2003-02-27
3
Medium Priority
?
362 Views
Last Modified: 2013-11-20
What do I need to include and/or link to to use CDaoDatabase objects?  I don't want to have to use the AppWizard for DB support... I'm sure it's easy, but it's a little hard to figure out which files to include, etc.

A little snippet showing how to instantiate and initialize a CDaoDatabase will get an extra 100 points.
0
Comment
Question by:smitty1276
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
Ess earned 800 total points
ID: 8040243
#include <afxdao.h> in your stdafx.h file.  Note that if you are using an Access 2000 file as your database you will also need to include AfxGetModuleState()->m_dwVersion = 0x0601 in your InitInstance() function, if you are linking with a shared MFC library.  If you do not do this you will get an error with access 2000 that states "unrecognized database format"  If you are using MFC in a static library you will need to rebuild the MFC library.  Details are on the Micorosft knowledge base.  For other versions you do not need to do this.

To use CDaoDatabase just do the following:

//Open the database
CDaoDatabase database;
database.Open("DatabaseFileName");
// Open a recordset
CDaoRecordset recordset(&database);
// Note the SQL statement takes the form "Select
//<something or *> from FieldName)
recordset.Open(dbOpenDynaset,"SQL statement to get records",0);
COleVariant Value;
//Get Field Values
recordset.GetFieldValue("FieldName",Value);
// Close the recordset and database
recordset.Close();
database.Close();

Hope this helps!!
0
 
LVL 2

Author Comment

by:smitty1276
ID: 8046429
I haven't tried it yet, but it should definately get me in the right direction!  Thanks...
0
 
LVL 1

Expert Comment

by:Ess
ID: 8049424
You should also include <afxdb.h> for ODBC database support probably.
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question