CRecordset Giving Error while Featching Data form MS Access Memo Field

CRecordset Giving Error while Featching Data form MS Access Memo Field

Post by Nithi Guru » Fri, 17 Oct 2003 06:40:45


ikarant:

Pass the Variant value you get for that memo field into the following
function. You will get the correct value:

CString VarToStr(_variant_t& var)
{
CString strRet;
strRet = _T("Fish");
switch(var.vt){
case VT_NULL:
case VT_EMPTY:
case VT_ERROR:
strRet = _T("");
break;
case VT_DECIMAL:
var.ChangeType(VT_BSTR);
strRet = VarToStr(var);
break;
case VT_I2:
strRet.Format(_T("%hd"),V_I2(&var));
break;
case VT_I4:
strRet.Format(_T("%d"),V_I4(&var));
break;
case VT_R4:
strRet.Format(_T("%e"),(double)V_R4(&var));
break;
case VT_R8:
strRet.Format(_T("%e"),V_R8(&var));
break;
case VT_CY:
strRet = COleCurrency(var).Format();
break;
case VT_DATE:
strRet = COleDateTime(var).Format(DATETIMEFORMAT);
break;
case VT_BSTR:
strRet = V_BSTR(&var);
break;
case VT_DISPATCH:
strRet = _T("VT_DISPATCH");
break;
case VT_BOOL:
return ( V_BOOL(&var) ? _T("1") : _T("0"));
case VT_VARIANT:
strRet = _T("VT_VARIANT");
break;
case VT_UNKNOWN:
strRet = _T("VT_UNKNOWN");
break;
case VT_I1:
strRet.Format(_T("%d"), V_I1(&var));
break;
case VT_UI1:
strRet.Format(_T("%u"), V_UI1(&var));
break;
case VT_UI2:
strRet = _T("VT_UI2");
break;
case VT_UI4:
strRet = _T("VT_UI4");
break;
case VT_I8:
strRet = _T("VT_I8");
break;
case VT_UI8:
strRet = _T("VT_UI8");
break;
case VT_INT:
strRet = _T("VT_INT");
break;
case VT_UINT:
strRet = _T("VT_UINT");
break;
case VT_VOID:
strRet = _T("VT_VOID");
break;
case VT_HRESULT:
strRet = _T("VT_HRESULT");
break;
case VT_PTR:
strRet = _T("VT_PTR");
break;
case VT_SAFEARRAY:
strRet = _T("VT_SAFEARRAY");
break;
case VT_CARRAY:
strRet = _T("VT_CARRAY");
break;
case VT_USERDEFINED:
strRet = _T("VT_USERDEFINED");
break;
case VT_LPSTR:
strRet = _T("VT_LPSTR");
break;
case VT_LPWSTR:
strRet = _T("VT_LPWSTR");
break;
case VT_FILETIME:
strRet = _T("VT_FILETIME");
break;
case VT_BLOB:
strRet = _T("VT_BLOB");
break;
case VT_STREAM:
strRet = _T("VT_STREAM");
break;
case VT_STORAGE:
strRet = _T("VT_STORAGE");
break;
case VT_STREAMED_OBJECT:
strRet = _T("VT_STREAMED_OBJECT");
break;
case VT_STORED_OBJECT:
strRet = _T("VT_STORED_OBJECT");
break;
case VT_BLOB_OBJECT:
strRet = _T("VT_BLOB_OBJECT");
break;
case VT_CF:
strRet = _T("VT_CF");
break;
case VT_CLSID:
 
 
 

CRecordset Giving Error while Featching Data form MS Access Memo Field

Post by Rob » Fri, 17 Oct 2003 17:56:22

Please change your system clock, this is the second time you have posted
with an advanced date

 
 
 

CRecordset Giving Error while Featching Data form MS Access Memo Field

Post by Nithi Guru » Sat, 18 Oct 2003 02:04:18

Code sample to access using ADO:

_RecordsetPtr adoRs;
adoRs.CreateInstance(__uuidof(Recordset));
adoRs->Open(m_strSql, _variant_t((IDispatch *)lpConn,
true),adOpenForwardOnly, adLockReadOnly, adCmdText);

adoRs->Collect["MyColumnName"]) ===> gives the value as variant object (of
type "_variant_t")

Hope that helps!



Field
 
 
 

CRecordset Giving Error while Featching Data form MS Access Memo Field

Post by vikran » Sat, 18 Oct 2003 05:37:37

I am sorry for the same.
In future i will take care of it before posting.
 
 
 

CRecordset Giving Error while Featching Data form MS Access Memo Field

Post by vikran » Wed, 22 Oct 2003 09:18:28

Hey Friends

I am using Class Wizard Generated CRecordset inherited class to read/write
data to an MS Access Table(2000).Now When I try to read the Data from the
Field Which is having Memo Data type it gives me error

Data Truncated

Also in some conditions My recordset do not store data properly ie stores
garbage value in the Memo Field.

Sample Garbage :-





Plz Help
 
 
 

CRecordset Giving Error while Featching Data form MS Access Memo Field

Post by vikran » Sat, 25 Oct 2003 05:47:08

Hi "Nithi Gurusamy"
Thanks for the help.
while browsing through the MFC Code for TEXT fields i found that
the function
RFX_Text accepts another parameter which is the maximum length of the Field
for now I just used
RFX_Text(pFX, _T("[v_products_description_1]"),
m_v_products_description_1,999999);

I know this is just a patch but i will be analysing your code and will let
you informed about the same.
in order to use the code
i will have to use
GetFieldValue function of CRecordset
am i right ?
just asking
vikrant