Hi, I'm a student.
During homework, There is a problem.
Connect to MS SQL SERVER 2014 is OK. And Add class for Stored Procedure in SQL SERVER.
Here is the code.
[DB class]
class CRegister_StudentAccessor
{
public:
LONG m_RETURN_VALUE;
LONG m_SID;
LONG m_PASSWORD;
TCHAR m_GENDER[21];
TCHAR m_MAJOR[21];
LONG m_Curri_Year;
TCHAR m_Phone_Number[21];
TCHAR m_SNAME[21];
TCHAR m_ADDRESS[21];
....
};
template <class T>
class CRegister_Student : public CCommand<CAccessor<CRegister_StudentAccessor>, CNoRowset >
{
public:
HRESULT OpenAll()
{
HRESULT hr;
hr = OpenDataSource();
if (FAILED(hr))
return hr;
__if_exists(GetRowsetProperties)
{
CDBPropSet propset(DBPROPSET_ROWSET);
__if_exists(HasBookmark)
{
if( HasBookmark() )
propset.AddProperty(DBPROP_IRowsetLocate, true);
}
GetRowsetProperties(&propset);
return OpenRowset(&propset);
}
__if_not_exists(GetRowsetProperties)
{
__if_exists(HasBookmark)
{
if( HasBookmark() )
{
CDBPropSet propset(DBPROPSET_ROWSET);
propset.AddProperty(DBPROP_IRowsetLocate, true);
return OpenRowset(&propset);
}
}
}
return OpenRowset();
}
HRESULT OpenRowset(DBPROPSET *pPropSet = NULL)
{
HRESULT hr = Open(m_session, NULL, pPropSet); <- // Fail Open
#ifdef _DEBUG
if(FAILED(hr))
AtlTraceErrorRecords(hr);
#endif
return hr;
}
void CloseAll()
{
Close();
ReleaseCommand();
CloseDataSource();
}
};
[Call OpenAll() function in button event function]
CRegister_Student<CRegister_StudentAccessor> info;
if (info.OpenAll() == S_OK)
{
AfxMessageBox("Success");
}
else
AfxMessageBox("Fail");
Result: Fail!!
But, If I don't use Stored Procedure, use just table, that code operate normally.
I set the break points at some places and I can get the place where result fail.
I have few knowledge about that.
So, I want to solve this problem by myself rather than getting direct answer.
Give me some directions of direct answer, please :(