-
大小: 3.11MB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2023-09-13
- 語(yǔ)言: 數(shù)據(jù)庫(kù)
- 標(biāo)簽: ADO??SERVER2008??
資源簡(jiǎn)介
ADO連接SQL Server 2008數(shù)據(jù)庫(kù)代碼完整工程打開即用,有使用用例

代碼片段和文件信息
//#include?
//#include
//#include
//#include?
//using?namespace?std;
//#import?“c:\program?files\common?files\system\ado\msado15.dll“?no_namespace?rename(“EOF“?“adoEOF“)
//
//void?main()
//{
// CoInitialize(NULL);
// _ConnectionPtr?sqlConnection;
// HRESULT?hr=sqlConnection.CreateInstance(__uuidof(Connection));
// if(FAILED(hr))
// {
// cout<<“_ConnectionPtr對(duì)象指針實(shí)例化失敗!!!“< // return?;
// }
// else
// {
// try?{
// _bstr_t?mystrConnect?=?“Data?Source=ADMIN-PC;Initial?Catalog=ZHY;Persist?Security?Info=True;User?ID=supercell;Password=supercell“?
// ;
// _bstr_t?strConnect=“Driver={sql?server};server=127.0.0.11433;uid=supercell;pwd=supercell;database=ZHY;“;
// //_bstr_t?strConnect=“Provider=SQLOLEDB;Server=127.0.0.11433;Database=PBMS;uid=sa;pwd=pp471006459;“;
// //_bstr_t?strConnect=“Provider=SQLOLEDB.1;Password=supercell;Persist?Security?Info=True;User?ID=supercell;“;
// //“Initial?Catalog=PBMS;Data?Source=127.0.0.11433“;
// //以上這三條strConnect語(yǔ)句都可以用!!看自己喜好選擇用吧
// //要注意修改用戶名uid、密碼pwd、數(shù)據(jù)庫(kù)名database,這三個(gè)參數(shù)均是你自己sql?server的數(shù)據(jù)庫(kù)信息
// sqlConnection->Open(strConnect““““adModeUnknown);
// }
// catch(_com_error?&e)
// {
// cout<ription()< // }
// //以上為C++使用ADO連接SQL?SERVER?2008數(shù)據(jù)庫(kù)代碼
//
// _RecordsetPtr?m_pRecordset;?//記錄集對(duì)象指針,用來(lái)執(zhí)行SQL語(yǔ)句并記錄查詢結(jié)果
//
// if(FAILED(m_pRecordset.CreateInstance(__uuidof(?Recordset?))))
// {
// cout<<“記錄集對(duì)象指針實(shí)例化失敗!“< // return;
// }
// //char?strSQL[]=“SELECT?*?FROM?Books“;
// try
// {
// //打開數(shù)據(jù)庫(kù),執(zhí)行SQL語(yǔ)句,如果你自己要用,注意此處也要修改啊,修改表名!!
// m_pRecordset->Open(“SELECT?*?FROM?Student“(IDispatch*)sqlConnectionadOpenDynamicadLockOptimistic?adCmdText);
// //m_pRecordset->Open(“SELECT?*?FROM?Student“(IDispatch*)sqlConnectionadOpenDynamicadLockOptimistic?adCmdText);
// }
// catch?(_com_error?&e)
// {
// cout?<ription()< // }
// try
// {
// m_pRecordset->MoveFirst();
// while(!m_pRecordset->adoEOF)
// {
// //查詢我的Books表中的列:書名!你要使用的話,自己作相關(guān)修改吧
// string?bookname=(char*)(_bstr_t)(m_pRecordset->Fields->GetItem(_variant_t(“Sno“))->Value);
// cout< // m_pRecordset->MoveNext();
// }
// }
// catch?(_com_error?&e)
// {
// cout?<ription()< // }
// }
// system(“pause“);
//}
////使用時(shí)注意代碼中我的說(shuō)明!!因?yàn)橐薷囊恍﹥?nèi)容!因?yàn)槊總€(gè)人登錄數(shù)據(jù)庫(kù)的登錄信息,鏈接的數(shù)據(jù)庫(kù)名均不一樣,所以要修改!!
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????2658??2013-04-04?21:17??CppSQLServer\CppSQLServer\CppSQL.cpp
?????文件???????7636??2013-04-18?20:17??CppSQLServer\CppSQLServer\CppSQLServer.cpp
?????文件???????2023??2013-04-18?20:16??CppSQLServer\CppSQLServer\CppSQLServer.h
?????文件???????1928??2013-04-11?20:01??CppSQLServer\CppSQLServer\CppSQLServer.h.bak
?????文件???????4250??2013-04-11?15:26??CppSQLServer\CppSQLServer\CppSQLServer.vcproj
?????文件???????1413??2013-04-18?20:18??CppSQLServer\CppSQLServer\CppSQLServer.vcproj.admin-PC.admin.user
?????文件????????159??2013-04-11?16:25??CppSQLServer\CppSQLServer\DbService.cpp
?????文件????????143??2013-04-11?15:26??CppSQLServer\CppSQLServer\DbService.h
?????文件???????7652??2013-04-11?20:02??CppSQLServer\CppSQLServer\Debug\BuildLog.htm
?????文件???????1871??2013-04-09?23:26??CppSQLServer\CppSQLServer\Debug\CppSQL.obj
?????文件????????663??2013-04-09?23:27??CppSQLServer\CppSQLServer\Debug\CppSQLServer.exe.em
?????文件????????728??2013-04-09?23:27??CppSQLServer\CppSQLServer\Debug\CppSQLServer.exe.em
?????文件????????621??2013-04-11?20:02??CppSQLServer\CppSQLServer\Debug\CppSQLServer.exe.intermediate.manifest
?????文件?????287881??2013-04-11?20:02??CppSQLServer\CppSQLServer\Debug\CppSQLServer.obj
?????文件?????102794??2013-04-11?20:02??CppSQLServer\CppSQLServer\Debug\DbService.obj
?????文件?????170900??2012-06-06?14:05??CppSQLServer\CppSQLServer\Debug\msado15.tlh
?????文件?????148926??2012-06-06?14:05??CppSQLServer\CppSQLServer\Debug\msado15.tli
?????文件?????????65??2013-04-11?20:02??CppSQLServer\CppSQLServer\Debug\mt.dep
?????文件?????124661??2013-04-11?20:02??CppSQLServer\CppSQLServer\Debug\Test.obj
?????文件?????871424??2013-04-11?20:02??CppSQLServer\CppSQLServer\Debug\vc90.idb
?????文件?????659456??2013-04-11?20:02??CppSQLServer\CppSQLServer\Debug\vc90.pdb
?????文件???????1696??2013-04-11?19:50??CppSQLServer\CppSQLServer\Test.cpp
?????文件???14830592??2013-04-18?20:18??CppSQLServer\CppSQLServer.ncb
?????文件????????902??2013-04-03?14:03??CppSQLServer\CppSQLServer.sln
????..A..H.?????57856??2013-04-18?20:18??CppSQLServer\CppSQLServer.suo
?????文件?????148992??2013-04-11?20:02??CppSQLServer\Debug\CppSQLServer.exe
?????文件?????897604??2013-04-11?20:02??CppSQLServer\Debug\CppSQLServer.ilk
?????文件????1682432??2013-04-11?20:02??CppSQLServer\Debug\CppSQLServer.pdb
?????目錄??????????0??2013-04-11?20:02??CppSQLServer\CppSQLServer\Debug
?????目錄??????????0??2013-04-18?20:17??CppSQLServer\CppSQLServer
............此處省略5個(gè)文件信息
評(píng)論
共有 條評(píng)論