HRESULT hr;
try
{
hr=m_pConnection.CreateInstance("ADODB.Connection");//创建connection对象
if (SUCCEEDED(hr))
{
m_pConnection->ConnectionTimeout=3;//set the timeout 3 seconds,
hr=m_pConnection->Open("driver={SQL Server};Server='LYPC';database='dbDocument';UID='sa';PWD='611009'","","",adModeUnknown);
if (hr)
{
AfxMessageBox("ok");
}
}
}
catch(_com_error e)///捕捉异常
{
CString errormessage;
errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage());
AfxMessageBox(errormessage);///显示错误信息
}
为什么总是说:未指定的错误。
try
{
hr=m_pConnection.CreateInstance("ADODB.Connection");//创建connection对象
if (SUCCEEDED(hr))
{
m_pConnection->ConnectionTimeout=3;//set the timeout 3 seconds,
hr=m_pConnection->Open("driver={SQL Server};Server='LYPC';database='dbDocument';UID='sa';PWD='611009'","","",adModeUnknown);
if (hr)
{
AfxMessageBox("ok");
}
}
}
catch(_com_error e)///捕捉异常
{
CString errormessage;
errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage());
AfxMessageBox(errormessage);///显示错误信息
}
为什么总是说:未指定的错误。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货