⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hack.cpp

📁 DAO读写ACCESS文件 DAO读写ACCESS文件
💻 CPP
字号:
// BY:    QQ:316118740
//博客 http://hi.baidu.com/alalmn
//希望能结识更多数据库开发的朋友
// hack.cpp : implementation file
//

#include "stdafx.h"
#include "ACCE.h"
#include "hack.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// Chack dialog


Chack::Chack(CWnd* pParent /*=NULL*/)
	: CDialog(Chack::IDD, pParent)
{
	//{{AFX_DATA_INIT(Chack)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void Chack::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Chack)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(Chack, CDialog)
	//{{AFX_MSG_MAP(Chack)
	ON_WM_CLOSE()
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Chack message handlers

BOOL Chack::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	SetDlgItemText(IDC_EDIT1, s1);
	SetDlgItemText(IDC_EDIT2, s2);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void Chack::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	s1="";
	s2="";
	CDialog::OnClose();
}

#include <afxdao.h>
CDaoDatabase db1;				//数据库   要加入头文件 #include <afxdao.h>
CDaoRecordset RecSet1(&db1);		//记录集
void Chack::OnButton1() 
{
	// TODO: Add your control notification handler code here
	CString a,b;
	GetDlgItemText(IDC_EDIT1,a);
	GetDlgItemText(IDC_EDIT2,b);

	CString sPath;
	GetModuleFileName(NULL,sPath.GetBufferSetLength (MAX_PATH+1),MAX_PATH);
	sPath.ReleaseBuffer ();
    int nPos;
	nPos=sPath.ReverseFind ('\\');
	sPath=sPath.Left (nPos);
	
	CString strFile = sPath + "\\demo.mdb";
	db1.Open(strFile);		// 打开已创建的demo数据库及DamoTable表
	CString szSql;
	szSql.Format("update DemoTable set Name='%s',Age='%s' where Name='%s'",a,b,a);
	db1.Execute(szSql);    //创建数据库表

//	RecSet1.Open(AFX_DAO_USE_DEFAULT_TYPE, szSql,NULL);

	//关闭记录集及库
	RecSet1.Close();
	db1.Close();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -