一般来说,是用Command.Execute 执行存储过程的另外,CRecordSet对象调用存储过程, 好像是可以的去msdn看了一下 CRecordset::Open virtual BOOL Open( UINT nOpenType = AFX_DB_USE_DEFAULT_TYPE, LPCTSTR lpszSQL = NULL, DWORD dwOptions = none );lpszSQLA string pointer containing one of the following: A NULL pointer. The name of a table. An SQL SELECT statement (optionally with an SQL WHERE or ORDER BY clause). A CALL statement specifying the name of a predefined query (stored procedure). Be careful that you do not insert whitespace between the curly brace and the CALL keyword.看整个意思,好像是可以打开一个stored procedure的 不过俺也没做过,不熟悉,呵呵
执行存储过程的另外,CRecordSet对象调用存储过程,
好像是可以的去msdn看了一下
CRecordset::Open
virtual BOOL Open( UINT nOpenType = AFX_DB_USE_DEFAULT_TYPE, LPCTSTR lpszSQL = NULL, DWORD dwOptions = none );lpszSQLA string pointer containing one of the following: A NULL pointer.
The name of a table.
An SQL SELECT statement (optionally with an SQL WHERE or ORDER BY clause).
A CALL statement specifying the name of a predefined query (stored procedure). Be careful that you do not insert whitespace between the curly brace and the CALL keyword.看整个意思,好像是可以打开一个stored procedure的
不过俺也没做过,不熟悉,呵呵
pDatabase->OpenEx("DSN=ODBCName;UID=***;PWD=***", 0 );
CRecordset rs( pDatabase );
SQL.Format("{call Test('%d','%d','%d','%d')}",Time0, Time1, Time2, Time3);
rs.Open( CRecordset::dynamic, SQL, CRecordset::readOnly );
if(rs.IsBOF()==0)
rs.MoveFirst(); //报错:提取类型超出范围
while(rs.IsEOF()==0)
{
rs.GetFieldValue( (long)0, strReturn );
....
rs.MoveNext();
}
rs.Close();
pDatabase->Close();
delete pDatabase;