Tree Control for database access

Source: Internet
Author: User

 


Add the content of the database to the tree control. Create a database and connect it with the tree control to access the database. The query structure is clear and easy to operate.
The method is described as follows:
1. Create a database: Create an Access database. For the database structure and content, see the access file of the package.
2. Creating a single document is not based on the Application project supported by the database. The View class inherits from CFormView.
Project name: Ppp, and view class name: CPppView.
3. Create a database set. The data source uses DAO connection and inherits from CDaoRecordset. The class name is CShengSet.
4. Add the data source header file supporting DAO connection to the Stdafx. h file.

# Include <afxwin. h>// MFC core and standard components
  
# Include <afxext. h>// MFC extensions
  
# Include <afxdisp. h>// MFC Automation classes
  
# Include <afxdao. h>// Add rows to Access the Access database of this view class
  
# Include <afxdtctl. h>// MFC support for Internet Explorer 4 Common Controls
  
# Ifndef _ AFX_NO_AFXCMN_SUPPORT
  
# Include <afxcen. h>// MFC support for Windows Common Controls
  
# Endif
  

5. Add the dataset header file to PppView. h.

# Include "ShengSet. h"
  

Define dataset variables at the same time

Public:
  
CShengSet* M_ShengSet;
  

6. Add the dataset header file to PppDoc. h.

# Include "ShengSet. h"
  

Define dataset variables at the same time

Public:
  
CShengSetM_ShengSet;
  

7. Add the tree control (IDC_TREE1) to the View class dialog box and define its variable name as m_treectrl;
8. Obtain the pointer to the dataset in the OnInitialUpdate () function of the PppView. cpp file.

CFormView: OnInitialUpdate ();
  
CPppDoc * pDoc = (CPppDoc *) GetDocument (); // get a pointer to the document class
  
& N

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.