MFC ODBC 参数不足,期待是 1,急。。。。
CStringCondition="[dbName]";CStringfilterstring;filterstring=Condition+"="+m_HitItem;...
CString Condition = "[dbName]" ;
CString filterstring;
filterstring = Condition+"="+m_HitItem ;
m_Set->Close() ;
m_Set->m_strFilter = filterstring ;
m_Set->Open( CRecordset::snapshot , _T("Select * from StaffInformation"), CRecordset::none) ;
运行的时候报错说参数不足,期待是 1,这个到底是哪里错了啊,急用。。。 展开
CString filterstring;
filterstring = Condition+"="+m_HitItem ;
m_Set->Close() ;
m_Set->m_strFilter = filterstring ;
m_Set->Open( CRecordset::snapshot , _T("Select * from StaffInformation"), CRecordset::none) ;
运行的时候报错说参数不足,期待是 1,这个到底是哪里错了啊,急用。。。 展开
1个回答
展开全部
BOOL CAdoConnection::Open(LPCTSTR lpszConnect,long lOptions)
{
ASSERT(m_pConnection != NULL);
ASSERT(AfxIsValidString(lpszConnect));
if (strcmp(lpszConnect, _T("")) != 0)
{
m_strConnect = lpszConnect;
}
if (m_strConnect.IsEmpty())
{
ASSERT(FALSE);
return FALSE;
}
if (IsOpen()) Close();
try
{
return (m_pConnection->Open(_bstr_t(LPCTSTR(m_strConnect)), "", "", lOptions) == S_OK);
}
catch (_com_error e)
{
TRACE(_T("Warning: 连接数据库发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
TRACE(_T("%s\r\n"), GetLastErrorText());
return ADOERROR_OPENDATABASE;
}
catch (...)
{
TRACE(_T("Warning: 连接数据库时发生未知错误:"));
}
return FALSE;
}
BOOL CAdoConnection::ConnectSQLServer(CString dbsrc, CString dbname, CString user, CString pass, long lOptions)
{
CString strConnect = _T("Provider=SQLOLEDB.1; Data Source=") + dbsrc +
_T("; Initial Catalog=") + dbname +
_T("; User ID=") + user +
_T("; PWD=") + pass;
return Open(LPCTSTR(strConnect), lOptions);
}
{
ASSERT(m_pConnection != NULL);
ASSERT(AfxIsValidString(lpszConnect));
if (strcmp(lpszConnect, _T("")) != 0)
{
m_strConnect = lpszConnect;
}
if (m_strConnect.IsEmpty())
{
ASSERT(FALSE);
return FALSE;
}
if (IsOpen()) Close();
try
{
return (m_pConnection->Open(_bstr_t(LPCTSTR(m_strConnect)), "", "", lOptions) == S_OK);
}
catch (_com_error e)
{
TRACE(_T("Warning: 连接数据库发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
TRACE(_T("%s\r\n"), GetLastErrorText());
return ADOERROR_OPENDATABASE;
}
catch (...)
{
TRACE(_T("Warning: 连接数据库时发生未知错误:"));
}
return FALSE;
}
BOOL CAdoConnection::ConnectSQLServer(CString dbsrc, CString dbname, CString user, CString pass, long lOptions)
{
CString strConnect = _T("Provider=SQLOLEDB.1; Data Source=") + dbsrc +
_T("; Initial Catalog=") + dbname +
_T("; User ID=") + user +
_T("; PWD=") + pass;
return Open(LPCTSTR(strConnect), lOptions);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询