0
votes

I have a MFC dialog based project,Now I want to add database with that project. I have no idea how to do this. can anybody provide the useful link?

Actually when I create a new dialog based MFC project, the database support is hide. So I want to ask that

MFC dialog base project support database or not

When I create new Dialog based MFC project

enter image description here

Database support is hide.

2

2 Answers

1
votes

You should better directly use CDatabase and CRecordset classes to open to the database, and read/write to the tables, or call SQL using different CRecordset objects.

You need only one CDatabase object, and attach it to different CRecordset instances (one at a time). You may directly use CRecordset and use GetFieldValue method in a loop (controlled by IsEOF method). Or you may inherit from CRecordset and implement DoFieldExchange. See here.

1
votes

The database support in appwizard is ment for doc/view architecture. It will quickly help you to create ODBC classes.

Definitely you can use database in MFC applications. you can use ODBC/ADO to connect to the database and access it. You can refer these sites

  1. http://www.informit.com/library/content.aspx?b=Visual_C_PlusPlus&seqNum=190
  2. http://msdn.microsoft.com/en-us/library/fk4h509a(VS.80).aspx
  3. http://msdn.microsoft.com/en-us/library/w2c4cthk%28v=vs.80%29.aspx