使用C++连接数据库
在学习写数据库连接程序,不会用MFC,下面写的有什么错误吗?为什么报这个错 1>.\ConnOrccleTest.rc(3) : fatal error RC1015: cannot open include file 'resource.h'.程序代码:
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","IsEOF") #include<iostream> using namespace std; class ConnectOracle { public: ::_ConnectionPtr m_pConnection; ::_RecordsetPtr m_pRecordset; ::_CommandPtr m_pCommand; public: ConnectOracle(); void OnInitADOConn(); }; void ConnectOracle::OnInitADOConn() { ::CoInitialize(NULL); HRESULT hr; try { hr = m_pConnection.CreateInstance(__uuidof(Connection)); _bstr_t strConnect = "driver = {SQL Server};Server = 192.168.1.152;DATABASE = QSSHGIS;UID=FOREVERGEO;PWD=FOREVERGEO"; hr = m_pConnection->Open(strConnect,"","",adModeUnknown); if (hr == S_OK) { cout<<"连接数据库成功!"<<endl; } } catch (_com_error e) { cout<<"连接数据库失败!\r\n错误信息:"<<e.Description()<<endl; } }