VC++µÄADOÁ¬½ÓAccess²½Öè
1:ÔÚStaAfx.h ÖÐÌí¼ÓÈçÏ´úÂë #import "C:\\Program Files\\Common Files \\System\\ado\\msado15.dll" no_namespace rename("EOF","adoEOF")rename("BOF","adoBOF")
2:ÔÚBOOL CXXXApp::InitInstance()Öгõʼ»¯COM»·¾³
::CoInitialize(NULL);
ÊÍ·ÅCOM»·¾³
::CoUninitialize();
3£ºÔÚCXXXAppÍ·ÎļþÖж¨ÒåÁ½¸öÖÇÄÜÖ¸Õëpublic
Ö¸ÏòRecordset¶ÔÏóµÄÖ¸Õë
_RecordsetPtr m_pRecordset;
Ö¸ÏòConnection¶ÔÏóµÄÖ¸Õë
_ConnectionPtr m_pConnection;
4:ÔÚvoid CXXXApp::OnInitADOConn()
{
//ÓÃÓÚÈ«¾Ö±äÁ¿µ÷ÓÃÁ¬½ÓÊý¾Ý¿â
try
{
//´´½¨Á¬½Ó¶ÔÏóʵÀý
m_pConnection.CreateInstance("ADODB.Connection");
//ÉèÖÃÁ¬½Ó×Ö·û´®
CString strConnect="DRIVER={Microsoft Access Driver/ (*.mdb)};uid=;pwd=;DBQ=canyin.mdb;";
//ʹÓÃopen·½·¨Á¬½ÓÊý¾Ý¿â
m_pConnection->Open((_bstr_t)strConnect,"","",adModeUnknown);
}
catch(_com_error e)
{
CString temp;
temp.Format("Á¬½ÓÊý¾Ý¿â´íÎóÐÅÏ¢£º%s",e.ErrorMessage());
::MessageBox(NULL,temp,"ÌáʾÐÅÏ¢",NULL);
}
}
5£ºvoid CXXXApp::ExitConnect()
{
//ÓÃÓÚÈ«¾Ö±äÁ¿µ÷ÓùرÕÊý¾Ý¿â
//¹Ø±Õ¼Ç¼¼¯
if(m_pRecordset!=NULL)
m_pRecordset->Close();
m_pConnection->Close;
}
5£º
<1> //´ò¿ªÊý¾Ý¿âÁ¬½Ó
OnInitADOConn();
1£© //´´½¨Á¬½Ó¶ÔÏóʵÀý
m_pConnection.CreateInstance("ADODB.Connection");
&n
Ïà¹ØÎĵµ£º
ÍøÉÏÒ»µÀ½ðɽµÄÃæÊÔÌ⣺
http://topic.csdn.net/u/20100524/14/0eff992a-2849-4db6-bdaa-d4a200e79b7c.html
Çë·Ö±ðÓÃC++µÄÃæÏò¶ÔÏóºÍ·ºÐÍ»úÖÆ£¬±àдʵÏÖTemplate MethodģʽµÄʾÀý´úÂ룬²¢±È½ÏÁ½ÖÖ·½Ê½¸÷×ÔµÄÓÅȱµã¡£
ÓÃÐ麯ÊýʵÏÖTemplate MethodµÄ·½Ê½¾Í²»¶à˵ÁË¡£Ó÷ºÐ͵ķ½Ê½ÊµÏÖ¶à̬ÔÚATLÀïÃæÓдóÁ¿µÄÓõ½£¡
·ºÐ͵ ......
CºÍC++ÖеÄÖ÷ÒªÊý¾ÝÀàÐͺÍ×Ö½Ú´óС(
C/C++µÄд·¨ÊDz»¿ÆѧºÍ²»ÑϽ÷µÄ¡£ÒòΪCºÍC++ËäÈ»ÓïÒ壬µ«ÊÇÉè¼Æ˼ÏëÊǽṹ»¯ÓëÃæÏò¶ÔÏó. C±ê×¼¹æ·¶ÓëC++µÄ±ê×¼¹æ·¶Ò²ÊÇÁ½¸öÎı¾¡£½üÀ´×ÐϸÑо¿ÁËËüÃǵÄÊý¾ÝÀàÐÍ£¬²ÅÖªµÀÆäÀ´ÁúÈ¥Âö£¬ÕæÕý×öµ½ÆäʵËùÒÔÈ»¡£
1¡¢CÓïÑÔ¶¨ÒåÁË5ÖÖ»ù±¾Êý¾ÝÀàÐÍ
char(×Ö·û), int(Õ ......
/*
* File: main.cpp
* Author: Vicky
*
* Created on 2010Äê5ÔÂ8ÈÕ, ÏÂÎç2:47
*/
#include <iostream>
using namespace std;
void swap(int x, int y) {
cout << "x and y swap before : " << x << "\t" << y << endl;
int i = x;
x = y;
y = i; ......
/*
* File: main.cpp
* Author: Vicky
*
* Created on 2010Äê5ÔÂ8ÈÕ, ÏÂÎç2:47
*/
#include <iostream>
using namespace std;
class A{
public:
A(){
cout << "Ö´Ðй¹Ô캯Êý´´½¨Ò»¸ö¶ÔÏó" << endl;
}
A(A&){
cout << "Ö´Ðп½±´º¯Êý¿½±´Ò»¸ö¶ ......