请问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;
}