Proud::CAdoCommand Class Reference
Inheritance diagram for Proud::CAdoCommand:

Public Member Functions

PROUDSRV_API CAdoCommand (ADODB::_Command *conn)
 
PROUDSRV_API void Prepare (ADODB::_Connection *connection, const String &storedProcName, ADODB::CommandTypeEnum cmdType=ADODB::adCmdStoredProc)
 
PROUDSRV_API void Execute (OUT long *recordsAffected=NULL)
 
PROUDSRV_API void Execute (OUT CAdoRecordset &outRecordset, OUT long *recordsAffected=NULL)
 
PROUDSRV_API CVariant GetParam (int index)
 
PROUDSRV_API void SetParam (int index, const CVariant &value)
 
PROUDSRV_API ADODB::_ParameterPtr AppendParameter (const String &paramName, ADODB::DataTypeEnum paramType, ADODB::ParameterDirectionEnum paramDirection, const CVariant &defaultValue)
 
PROUDSRV_API ADODB::_ParameterPtr AppendParameter (const String &paramName, ADODB::DataTypeEnum paramType, ADODB::ParameterDirectionEnum paramDirection, const String &defaultValue)
 
PROUDSRV_API ADODB::_ParameterPtr AppendParameter (ADODB::DataTypeEnum paramType, ADODB::ParameterDirectionEnum paramDirection, const String &defaultValue)
 
PROUDSRV_API ADODB::_ParameterPtr AppendParameter (const String &paramName, ADODB::DataTypeEnum paramType, ADODB::ParameterDirectionEnum paramDirection)
 
PROUDSRV_API ADODB::_ParameterPtr AppendParameter (const String &paramName, ADODB::DataTypeEnum paramType, ADODB::ParameterDirectionEnum paramDirection, const String &defaultValue, long length)
 
PROUDSRV_API ADODB::_ParameterPtr AppendInputParameter (const String &paramName, const Guid &value)
 
PROUDSRV_API ADODB::_ParameterPtr AppendReturnValue ()
 

Additional Inherited Members

PROUDSRV_API void ExecuteBegin ()
 
PROUDSRV_API void ExecuteEnd (const String &command)
 

Detailed Description

This is a class wrapping ADO Command object.

How to call stored procedure with this method is shown in below.

  • Set stored procedure and active connection to call as Prepare.
  • Set input arguments with Parameters member.
  • Call already prepared stored procedure with Execute.
  • Get output argument with Parameters member.

Member Function Documentation

PROUDSRV_API ADODB::_ParameterPtr Proud::CAdoCommand::AppendInputParameter ( const String paramName,
const Guid value 
)

Convenient function for AppendParameter.

PROUDSRV_API ADODB::_ParameterPtr Proud::CAdoCommand::AppendParameter ( const String paramName,
ADODB::DataTypeEnum  paramType,
ADODB::ParameterDirectionEnum  paramDirection,
const CVariant defaultValue 
)

Add parameter value. This is not commonly used in MsSQL, but this method must be used in MySQL instead of SetParam.

Returns
Created _ParameterPtr
Parameters
paramNameName of parameter procedure to call for
paramTypeRefer to Data Type ADODB::DataTypeEnum
paramDirectionRefer to Data insertion direction ADODB::ParameterDirectionEnum.(MySQL must use adParamInput only. Output is not supported.)
defaultValueValue that will be passed to the actual procedure
PROUDSRV_API ADODB::_ParameterPtr Proud::CAdoCommand::AppendParameter ( const String paramName,
ADODB::DataTypeEnum  paramType,
ADODB::ParameterDirectionEnum  paramDirection,
const String defaultValue 
)

Refer to the same method

Parameters
defaultValueString value of the actual procedure
PROUDSRV_API ADODB::_ParameterPtr Proud::CAdoCommand::AppendParameter ( const String paramName,
ADODB::DataTypeEnum  paramType,
ADODB::ParameterDirectionEnum  paramDirection 
)

Refer to the same method but internally _variant_t will be added

PROUDSRV_API ADODB::_ParameterPtr Proud::CAdoCommand::AppendParameter ( const String paramName,
ADODB::DataTypeEnum  paramType,
ADODB::ParameterDirectionEnum  paramDirection,
const String defaultValue,
long  length 
)

Refer to the same method

Parameters
defaultValueString value of the actual procedure
lengthThe maximum length of string
PROUDSRV_API void Proud::CAdoCommand::Execute ( OUT long *  recordsAffected = NULL)

Execute the appointed stored procedure at PrepareSP.

Parameters
recordsAffectedNumber of records affected by stored procedure
PROUDSRV_API void Proud::CAdoCommand::Execute ( OUT CAdoRecordset outRecordset,
OUT long *  recordsAffected = NULL 
)

Execute the appointed stored procedure at PrepareSP.

Parameters
outRecordsetRecordset of results to get.
recordsAffectedNumber of records affected by stored procedure
PROUDSRV_API CVariant Proud::CAdoCommand::GetParam ( int  index)

Get parameter value of nth pointed by index. This can be used after PrepareSP is called.

Returns
Returned parameter value.
Parameters
Whichnth of parameter value do you want to get? 0 is return value of stored procedure and the res of parameters are 1-based index.
PROUDSRV_API void Proud::CAdoCommand::Prepare ( ADODB::_Connection *  connection,
const String storedProcName,
ADODB::CommandTypeEnum  cmdType = ADODB::adCmdStoredProc 
)

This method sets ready to call stored procedure. Meaning, it prepares ADO Connection, stored procedure name and inout argument.

Parameters
connection
storedProcName
PROUDSRV_API void Proud::CAdoCommand::SetParam ( int  index,
const CVariant value 
)

This method sets value of nth parameter pointed by index. It can be used after PrepareSP is called.

Parameters
indexWhich nth parameter value do you want to set? 0 is return value of stored procedure and the res of parameters are 1-based index.
valueSetting paramter value

NOTE This function is very slow because of executing an additional stored procedure for getting procedure information. It is not recommended to use this function. The workaround is to use AppendParameter() instead.