Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CRecordSet stored procedure

64 views
Skip to first unread message

V.@discussions.microsoft.com Patrick V.

unread,
Feb 19, 2009, 10:06:02 AM2/19/09
to
I have created a stored procedure on my SQL Server 2005 DataBase.
The SQL command to execute my procedure is "EXEC procedure_name[param]"

On VC++6.0, CRecordset::Open method fails with an exception error : "Attempt
to open a table failed - there were no columns to retrieve were specified."
Inside the MFC code, CRecordset::BuildSelectSQL() method fails :
"ThrowDBException(AFX_SQL_ERROR_EMPTY_COLUMN_LIST);"

I have noticed an issue in the BuildSelectSQL) method.
at this line :

// Ignore queries with procedure call keyword or output param
if (!(_tcsnicmp(m_strSQL, _afxCall, lstrlen(_afxCall)-1) == 0 ||
_tcsnicmp(m_strSQL, _afxParamCall, lstrlen(_afxParamCall)-1) == 0))

In this case, a procedure exec keyword is not ignore.

It works with CALL keyword and not with EXEC[UTE] keyword.


Paul S. Ganney

unread,
Apr 1, 2009, 4:55:53 AM4/1/09
to
It all depends on whether or not the procedure returns anything.

If it doesn't, then use CDatabase::ExecuteSQL().

If it does, then the CRecordset-derived class requires some bound
fields to place the results into. Take a look at my article on
CodeProject (http://www.codeproject.com/KB/database/CountSet.aspx),
which'll give you some ideas of where to put the code.

HTH

Paul.

0 new messages