1. vc使用mysql数据库
mysql数据库的使用和普通的库使用方法一样。将其头文件目录和库文件目录在tools下面的option里面添加。然后将mysql.h的头文件加入到stdafx.h中。如果在工程设置中没有添加了依赖项libmysql.lib,则需要添加#progama comment(lib,"libmysql.lib"). 如果仍然编译不过,则添加头文件 #“winsock.h" 。然后其中的mysql可以使用。接口在mysql.h中。
2.vc ado连接excel
ado在windows系统下其库默认在c:\program files\common files\system\ado\msado15.dll 。将其导入;在stdafx.h中加入#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename ("EOF", "adoEOF")
然后使用。
如下:
CoInitialize(NULL);
_ConnectionPtr pConn(_uuidof(Connection));
_RecordsetPtr pRst(_uuidof(Recordset));
_CommandPtr pCmd(_uuidof(Command));
pConn->ConnectionString = "Provider = Microsoft Jet.OLEDB.4.0;Data source=student.mdb";
pCmd->put_ActiveConnection(_variant_t((IDispatch*)pConn));
pCmd->CommandText = "select * from stu";
pRst = pCmd->Execute(NULL,NULL,adCmdText);
while(!pRst->adoEOF)
{
//((CListBox*)GetDlgItem(IDC_LIST1)->AddString((_bstr_t)pRst->GetCollect("学号")));
pRst->MoveNext();
}
pRst->Close();
pConn->Close();
pCmd->Release();
pRst.Release();
pConn.Release();
CoUninitialize();
3. odbc 使用 添加头文件#include "C:\Program Files\Microsoft Visual Studio\VC98\MFC\Include\AFXDB.H"
使用的都在afxdb.h中 具体参考