新微赢技术网
标题:
请问ADO连接SQLServer这样写对吗?
[打印本页]
作者:
紫恋
时间:
2009-11-3 03:21
标题:
请问ADO连接SQLServer这样写对吗?
_bstr_t strConnection = "Provider=SQLOLEDB;Server=.;Database=student;uid=sa;pwd=;";
try
{
HRESULT hr;
//创建Connection对象
hr = m_pConnection.CreateInstance("ADODB.Connection");
if(SUCCEEDED(hr))
{
//连接数据库
hr = m_pConnection->Open(strConnection,"","",NULL);
}
else
{
m_bOpen = false;
return m_bOpen;
}
}
catch(...)
{
MessageBox("连接数据库失败,请确认数据库student");
m_bOpen = false;
}
作者:
`|楛纞♂ぺ﹖
时间:
2009-11-3 03:21
hr = m_pConnection.CreateInstance("ADODB.Connection");
这句似醮砹?lt;BR>改成
hr = m_pConnection.CreateInstance(__uuidof(Connection));
hr = m_pConnection->Open("Provider=SQLOLEDB;Server=.;Database=student;uid=sa;pwd=;","","",adConnectUnspecified);
作者:
carsoom
时间:
2009-11-3 14:05
天使之所以会飞,是因为她们把自己看得很轻 ……
欢迎光临 新微赢技术网 (http://bbs.weiying.cn/)
Powered by Discuz! X3.2