Click here to Skip to main content
16,011,120 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to pass a CList to another function? Pin
John Wong19-Sep-02 9:39
John Wong19-Sep-02 9:39 
GeneralUNICODE and DataBases Pin
Member 14905119-Sep-02 7:54
Member 14905119-Sep-02 7:54 
GeneralRe: UNICODE and DataBases Pin
Michael Dunn19-Sep-02 8:02
sitebuilderMichael Dunn19-Sep-02 8:02 
GeneralRe: UNICODE and DataBases Pin
Anonymous19-Sep-02 8:34
Anonymous19-Sep-02 8:34 
GeneralDelay Loading of DLLs Pin
Rohit  Sinha19-Sep-02 7:33
Rohit  Sinha19-Sep-02 7:33 
GeneralRe: Delay Loading of DLLs Pin
Michael Dunn19-Sep-02 7:52
sitebuilderMichael Dunn19-Sep-02 7:52 
GeneralReturn value from a stored procedure in ADO Pin
youssef19-Sep-02 7:33
youssef19-Sep-02 7:33 
GeneralRe: Return value from a stored procedure in ADO Pin
TyMatthews19-Sep-02 9:15
TyMatthews19-Sep-02 9:15 
Assuming your stored proc looks something like this:

create procedure my_proc( @param1 int )
as
begin
   return 1
end


here's how you'd code it up with ADO:

#define ADO_TESTHR(x)	{	if FAILED(x) _com_issue_error(x);	};
 
_ConnectionPtr pConn;
_CommandPtr pCmd;
_variant_t vtValue;
 
try
{   
    ADO_TESTHR( pConn.CreateInstance( "ADODB.Connection" ) );
    ADO_TESTHR( pCmd.CreateInstance( "ADODB.Command" ) );
 
    .. open your connection  pConn->Open something
 
    pCmd->ActiveConnection = pConn;
    pCmd->CommandText = "dbo.my_cool_proc";   // The name of your proc
    pCmd->CommandType = adCmdStoredProc;
 
    // Add the proc parameters
    pCmd->Parameters->Append( pCmd->CreateParameter( "param1", adInteger, adParamInput, sizeof(int) ) );
     
    // Add the return parameter.  This MUST be the last parameter appended
    pCmd->Parameters->Append( pCmd->CreateParameter( "return", adInteger, adParamReturnValue, sizeof(int) ) );
 
    // Set the parameter value  
    pCmd->Parameters->Item["param1"]->Value = 1234;
 
    pCmd->Execute( NULL, NULL, adCmdStoredProc );
 
    // Check out the return value
    vtValue = pCmd->Parameters->Item["return"]->Value;
    if( vtValue.vt == VT_I4 )
    {
        TRACE( "%lu\n", static_cast< long >( vtValue ) );
    }		
  
}
catch( _com_error &ce )
{
}
 
try
{
   if( pConn )
   {
      if( pConn->State != adStateClosed )
      {
          pConn-Close();
      }
   }
}
catch( ... )
{
}


Ty


"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein


GeneralRe: Return value from a stored procedure in ADO Pin
youssef20-Sep-02 3:14
youssef20-Sep-02 3:14 
GeneralRe: Return value from a stored procedure in ADO Pin
TyMatthews20-Sep-02 5:36
TyMatthews20-Sep-02 5:36 
GeneralRe: Return value from a stored procedure in ADO Pin
youssef20-Sep-02 5:48
youssef20-Sep-02 5:48 
GeneralRe: Return value from a stored procedure in ADO Pin
TyMatthews20-Sep-02 5:50
TyMatthews20-Sep-02 5:50 
GeneralRe: Return value from a stored procedure in ADO Pin
Carlos Antollini20-Sep-02 6:09
Carlos Antollini20-Sep-02 6:09 
GeneralRe: Return value from a stored procedure in ADO Pin
youssef20-Sep-02 7:38
youssef20-Sep-02 7:38 
GeneralRe: Return value from a stored procedure in ADO Pin
youssef20-Sep-02 10:16
youssef20-Sep-02 10:16 
Generalout of memory Pin
SamirSood19-Sep-02 7:15
SamirSood19-Sep-02 7:15 
GeneralRe: out of memory Pin
jmkhael19-Sep-02 7:42
jmkhael19-Sep-02 7:42 
GeneralRe: out of memory Pin
SamirSood19-Sep-02 20:37
SamirSood19-Sep-02 20:37 
GeneralTwo dimensional array Pin
needhelp5719-Sep-02 7:04
needhelp5719-Sep-02 7:04 
GeneralRe: Two dimensional array Pin
User 988519-Sep-02 7:04
User 988519-Sep-02 7:04 
GeneralRe: Two dimensional array Pin
needhelp5721-Sep-02 10:55
needhelp5721-Sep-02 10:55 
GeneralRe: Two dimensional array Pin
Michael Dunn19-Sep-02 7:53
sitebuilderMichael Dunn19-Sep-02 7:53 
GeneralRe: Two dimensional array Pin
valikac19-Sep-02 10:00
valikac19-Sep-02 10:00 
Generalmemory mapped file Pin
User 988519-Sep-02 6:43
User 988519-Sep-02 6:43 
GeneralRe: memory mapped file Pin
valikac19-Sep-02 10:06
valikac19-Sep-02 10:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.