::CoInitialize(NULL);
HRESULT hr = m_pConn.CreateInstance("ADODB.Connection"); //创建Connection对象
if(!SUCCEEDED(hr))
return;
_bstr_t strConnect = "Provider=SQLNCLI;Data Source=服务器;Initial Catalog=数据库名;User Id=sa;Password=密码;";
(例如:_bstr_t strConnect = "Provider=SQLNCLI;Data Source=127.0.0.1;Initial Catalog=TestDB;User Id=sa;Password=000000;";)
hr = m_pConn->Open(strConnect.c_str(), "", "", -1);
(_ConnectionPtr m_pConn)
O了!
posted on 2012-10-04 14:45
小王 阅读(282)
评论(0) 编辑 收藏 引用 所属分类:
DB