积极答复者
关于ADO连接SQL的问提??

问题
-
void C数据库1Dlg::OnBnClickedOk() { // TODO: 在此添加控件通知处理程序代码 CoInitialize(NULL); //AfxOleInit(); _ConnectionPtr pConn(__uuidof(Connection)); _RecordsetPtr pRst(__uuidof(Recordset)); _CommandPtr pCmd(__uuidof(Command));//实例化一个Command对象pCmd if (FAILED(pConn.CreateInstance("ADODB.Connection"))) { AfxMessageBox(L"Create Instance failed!"); return; } try { pConn->ConnectionString="Data Sourct=PC;Integrated=SSPI;Database=ebook;"; AfxMessageBox(L"连接成功"); } catch(_com_error e) { AfxMessageBox(L"连接失败" +e.Description()); } }
当我把Database变成根本没有的名称,还是会提示连接成功。。。
请问各位高手下,我的这段代码有什么问题吗?多谢各位了啊!!!!!
- 已移动 Andrew.Wu 2011年6月17日 2:56 (发件人:Visual Studio 相关讨论(Visual Studio 2010以前版本))
答案
-
你好,
我把这篇帖子移到了VC++论坛,你可以在这边得到更好的回复。
谢谢你的理解与支持。
Andrew Wu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 pxvs2008 2011年6月19日 11:56
-
参考http://support.microsoft.com/kb/169496/EN-US
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP- 已标记为答案 pxvs2008 2011年6月19日 11:56
全部回复
-
你好,
我把这篇帖子移到了VC++论坛,你可以在这边得到更好的回复。
谢谢你的理解与支持。
Andrew Wu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 pxvs2008 2011年6月19日 11:56
-
忘记调用Open了
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP -
参考http://support.microsoft.com/kb/169496/EN-US
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP- 已标记为答案 pxvs2008 2011年6月19日 11:56
-
ADO里面的"A"是ActiveX,当然要初始化COM
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP