Mitch Wittneben
April 26th, 1999, 07:30 AM
I have a problem calling a stored procedure that contains output parameters
from a VC 6.0 app. I normally call an sp with the following syntax:
CString strSQL="{Call spTest(1)}";
m_App->m_Database->ExecuteSQL(strSQL);
this works fine, but now I need to call an sp with output parameters. My sp
is defined as follows:
create procedure spAddTransaction
@CustomerID int, @record int output
as
insert Transactions (CustomerID) values (@CustomerID)
select @record=@@identity
go
and I am trying to call it in VC with the following code:
CString strSQL="{Call spAddTransaction(1,test)}";
try{
m_App->m_Recordset->Open(CRecordset::dynaset,m_App->m_strSQL,CRecordset::non
e);
}
catch (CDBException* e){
AfxMessageBox(e->m_strError,MB_OK | MB_ICONINFORMATION);
e->Delete();
return;
}
while (!m_App->m_Recordset->IsEOF()){
m_App->m_Recordset->GetFieldValue((short)0,m_App->m_varField);
m_App->m_Recordset->MoveNext();
}
m_App->m_Recordset->Close();
but it does not work complaining that test is an undefined cursor. Is there
a way without deriving a class for the sp to call an sp without ouput
parameters. Thanks in advance.
--mitch
from a VC 6.0 app. I normally call an sp with the following syntax:
CString strSQL="{Call spTest(1)}";
m_App->m_Database->ExecuteSQL(strSQL);
this works fine, but now I need to call an sp with output parameters. My sp
is defined as follows:
create procedure spAddTransaction
@CustomerID int, @record int output
as
insert Transactions (CustomerID) values (@CustomerID)
select @record=@@identity
go
and I am trying to call it in VC with the following code:
CString strSQL="{Call spAddTransaction(1,test)}";
try{
m_App->m_Recordset->Open(CRecordset::dynaset,m_App->m_strSQL,CRecordset::non
e);
}
catch (CDBException* e){
AfxMessageBox(e->m_strError,MB_OK | MB_ICONINFORMATION);
e->Delete();
return;
}
while (!m_App->m_Recordset->IsEOF()){
m_App->m_Recordset->GetFieldValue((short)0,m_App->m_varField);
m_App->m_Recordset->MoveNext();
}
m_App->m_Recordset->Close();
but it does not work complaining that test is an undefined cursor. Is there
a way without deriving a class for the sp to call an sp without ouput
parameters. Thanks in advance.
--mitch