?? adocommand.cpp
字號:
}
catch (_com_error e)
{
TRACE(_T("Warning: SetPrecision 方法發(fā)生異常. 錯(cuò)誤信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
/*========================================================================
Name: 指示 Parameter 對象的數(shù)據(jù)類型.
----------------------------------------------------------
Params: [DataType]: DataTypeEnum 類型值, 請參考 CRecordSet 類相關(guān)
函數(shù).
==========================================================================*/
BOOL CAdoParameter::SetType(DataTypeEnum DataType)
{
ASSERT(m_pParameter != NULL);
try
{
m_pParameter->PutType(DataType);
return TRUE;
}
catch (_com_error e)
{
TRACE(_T("Warning: SetType 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return adEmpty;
}
}
/*========================================================================
Name: 表示 Parameter 對象的最大大小(按字節(jié)或字符)。
----------------------------------------------------------
Params: [size]: 表示 Parameter 對象的最大大小(按字節(jié)或字符)的長
整型值。
==========================================================================*/
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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return CString(_T(""));
}
}
/*========================================================================
Name: 指示 Parameter 所標(biāo)明的是輸入?yún)?shù)、輸出參數(shù)還是既是輸出又
是輸入?yún)?shù),或該參數(shù)是否為存儲(chǔ)過程返回的值。
----------------------------------------------------------
Params: [Direction]: 設(shè)置以下某個(gè) ParameterDirectionEnum 值。
[常量] [說明]
-------------------------------------------
AdParamUnknown 指示參數(shù)方向未知。
AdParamInput 默認(rèn)值。指示輸入?yún)?shù)。
AdParamOutput 指示輸出參數(shù)。
AdParamInputOutput 同時(shí)指示輸入?yún)?shù)和輸出參數(shù)。
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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %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 方法發(fā)生異常. 錯(cuò)誤信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -