Share via


CDaoRecordset::SetParamValue

Call this member function to set the value of a parameter in the recordset at run time.

virtual void SetParamValue( 
   int nIndex, 
   const COleVariant& varValue  
); 
virtual void SetParamValue( 
   LPCTSTR lpszName, 
   const COleVariant& varValue  
);

Parameters

  • nIndex
    The numerical position of the parameter in the querydef's Parameters collection.

  • var
    The value to set; see Remarks.

  • lpszName
    The name of the parameter whose value you want to set.

Remarks

The parameter must already have been established as part of the recordset's SQL string. You can access the parameter either by name or by its index position in the collection.

Specify the value to set as a COleVariant object. For information about setting the desired value and type in your COleVariant object, see class COleVariant. Note that if you are not creating a UNICODE recordset, the COleVariant object must be explicitly declared ANSI. This can be done by using the COleVariant::COleVariant( lpszSrc**,** vtSrc ) form of constructor with vtSrc set to VT_BSTRT (ANSI) or by using the COleVariant function SetString( lpszSrc**,** vtSrc ) with vtSrc set to VT_BSTRT.

Requirements

Header: afxdao.h

See Also

Reference

CDaoRecordset Class

Hierarchy Chart

CDaoRecordset::GetParamValue

CDaoRecordset::m_nParams

CDaoRecordset::SetParamValueNull