求助在ado连接access时_ConnectionPtr设定
请问:我在用ado访问 access数据库时
语句放在:
void CTest2View::OnConnect()
{
::CoInitialize(NULL);
_ConnectionPtr Conn;
if (FAILED(pConn.CreateInstance("ADODB.Connection")))
{
AfxMessageBox("Create Instance failed!");
return;
}
CString strSRC;
strSRC="Driver=SQL Server;Server=202.103.*.*;Database=***;UID=sa;PWD=***";
CString strSQL;
_variant_t varSRC(strSRC);
_variant_t varSQL(strSQL);
_bstr_t bstrSRC(strSRC);
if (FAILED(Conn->Open(bstrSRC,"","",-1)))
{
AfxMessageBox("Can not open Database!");
Conn.Release();
pConn=Conn;
return;
}
}
中
老实出现一对错误,说我_ConnectionPtr Conn;没定义?!
请指点阿