📄 adocommand.cpp
字号:
}
catch (_com_error e)
{
TRACE(_T("Warning: SetPrecision 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
/*========================================================================
Name: 指示 Parameter 对象的数据类型.
----------------------------------------------------------
Params: [DataType]: DataTypeEnum 类型值, 请参考 CRecordSet 类相关
函数.
==========================================================================*/
BOOL CAdoParameter::SetType(DataTypeEnum DataType)
{
ASSERT(m_pParameter != NULL);
try
{
m_pParameter->PutType(DataType);
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: SetType 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
DataTypeEnum CAdoParameter::GetType()
{
ASSERT(m_pParameter != NULL);
try
{
return m_pParameter->GetType();
}
catch (_com_error e)
{
TRACE(_T("Warning: SetDirection 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return adEmpty;
}
}
/*========================================================================
Name: 表示 Parameter 对象的最大大小(按字节或字符)。
----------------------------------------------------------
Params: [size]: 表示 Parameter 对象的最大大小(按字节或字符)的长
整型值。
==========================================================================*/
BOOL CAdoParameter::SetSize(int size)
{
ASSERT(m_pParameter != NULL);
try
{
m_pParameter->PutSize(long(size));
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: SetSize 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
int CAdoParameter::GetSize()
{
ASSERT(m_pParameter != NULL);
try
{
return (int)m_pParameter->GetSize();
}
catch (_com_error e)
{
TRACE(_T("Warning: SetDirection 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return -1;
}
}
/*========================================================================
Name: 指示对象的名称。
==========================================================================*/
BOOL CAdoParameter::SetName(CString strName)
{
ASSERT(m_pParameter != NULL);
try
{
m_pParameter->PutName(_bstr_t(LPCTSTR(strName)));
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: SetName 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
CString CAdoParameter::GetName()
{
ASSERT(m_pParameter != NULL);
try
{
return CString(LPCTSTR(m_pParameter->GetName()));
}
catch (_com_error e)
{
TRACE(_T("Warning: SetName 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return CString(_T(""));
}
}
/*========================================================================
Name: 指示 Parameter 所标明的是输入参数、输出参数还是既是输出又
是输入参数,或该参数是否为存储过程返回的值。
----------------------------------------------------------
Params: [Direction]: 设置以下某个 ParameterDirectionEnum 值。
[常量] [说明]
-------------------------------------------
AdParamUnknown 指示参数方向未知。
AdParamInput 默认值。指示输入参数。
AdParamOutput 指示输出参数。
AdParamInputOutput 同时指示输入参数和输出参数。
AdParamReturnValue 指示返回值。
==========================================================================*/
BOOL CAdoParameter::SetDirection(ParameterDirectionEnum Direction)
{
ASSERT(m_pParameter != NULL);
try
{
m_pParameter->PutDirection(Direction);
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: SetDirection 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
ParameterDirectionEnum CAdoParameter::GetDirection()
{
ASSERT(m_pParameter != NULL);
try
{
return m_pParameter->GetDirection();
}
catch (_com_error e)
{
TRACE(_T("Warning: SetDirection 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return adParamUnknown;
}
}
/*########################################################################
------------------------------------------------
------------------------------------------------
########################################################################*/
BOOL CAdoParameter::SetValue(const _variant_t &value)
{
ASSERT(m_pParameter != NULL);
try
{
if (m_pParameter->Size == 0)
{
m_pParameter->Size = sizeof(VARIANT);
}
m_pParameter->Value = value;
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: GetValue 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
BOOL CAdoParameter::SetValue(const bool &value)
{
try
{
if (m_pParameter->Size == 0)
{
m_pParameter->Size = sizeof(short);
}
m_pParameter->Value = _variant_t(value);
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: SetValue 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
BOOL CAdoParameter::SetValue(const int &value)
{
try
{
if (m_pParameter->Size == 0)
{
m_pParameter->Size = sizeof(int);
}
m_pParameter->Value = _variant_t(long(value));
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: SetValue 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
BOOL CAdoParameter::SetValue(const long &value)
{
try
{
if (m_pParameter->Size == 0)
{
m_pParameter->Size = sizeof(long);
}
m_pParameter->Value = _variant_t(value);
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: SetValue 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
BOOL CAdoParameter::SetValue(const double &value)
{
try
{
if (m_pParameter->Size == 0)
{
m_pParameter->Size = sizeof(double);
}
m_pParameter->Value = _variant_t(value);
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: SetValue 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
BOOL CAdoParameter::SetValue(const CString &value)
{
_variant_t var;
var.vt = value.IsEmpty() ? VT_NULL : VT_BSTR;
var.bstrVal = value.AllocSysString();
try
{
if (m_pParameter->Size == 0)
{
m_pParameter->Size = value.GetLength();
}
m_pParameter->Value = var;
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: SetValue 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
BOOL CAdoParameter::SetValue(const COleDateTime &value)
{
_variant_t var;
var.vt = VT_DATE;
var.date = value;
try
{
if (m_pParameter->Size == 0)
{
m_pParameter->Size = sizeof(DATE);
}
m_pParameter->Value = var;
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: SetValue 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
return TRUE;
}
BOOL CAdoParameter::SetValue(const BYTE &value)
{
try
{
if (m_pParameter->Size == 0)
{
m_pParameter->Size = sizeof(BYTE);
}
m_pParameter->Value = _variant_t(value);
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: SetValue 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
BOOL CAdoParameter::SetValue(const short &value)
{
try
{
if (m_pParameter->Size == 0)
{
m_pParameter->Size = sizeof(short);
}
m_pParameter->Value = _variant_t(value);
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: SetValue 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
BOOL CAdoParameter::SetValue(const float &value)
{
try
{
if (m_pParameter->Size == 0)
{
m_pParameter->Size = sizeof(float);
}
m_pParameter->Value = _variant_t(value);
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: SetValue 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
BOOL CAdoParameter::GetValue(bool &value)
{
try
{
value = vartobool(m_pParameter->Value);
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: GetValue 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
BOOL CAdoParameter::GetValue(BYTE &value)
{
try
{
value = vartoby(m_pParameter->Value);
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: GetValue 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
BOOL CAdoParameter::GetValue(short &value)
{
try
{
value = vartoi(m_pParameter->Value);
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: GetValue 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
BOOL CAdoParameter::GetValue(int &value)
{
try
{
value = (int)vartol(m_pParameter->Value);
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: GetValue 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
BOOL CAdoParameter::GetValue(long &value)
{
try
{
value = vartol(m_pParameter->Value);
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: GetValue 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
BOOL CAdoParameter::GetValue(double &value)
{
try
{
value = vartof(m_pParameter->Value);
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: GetValue 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
BOOL CAdoParameter::GetValue(CString &value)
{
try
{
value = vartostr(m_pParameter->Value);
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: GetValue 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
BOOL CAdoParameter::GetValue(COleDateTime &value)
{
try
{
value = vartodate(m_pParameter->Value);
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: GetValue 方法发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -