DBSTATUS DBSTATUS;
DBTYPE DBTYPE;
CString Str;
Double Dvalue; Long Lvalue;
// Paccessor is a pointer to the CDynamicAccessor object
// ncol is the list of read columns
Paccessor-> GetStatus (ncol, & dbstatus);
IF (DBSTATUS! = dbstatus_s_isnull && paccessor-> getColumnType (ncol, & dbtype))
{
Switch (DBTYPE)
{
Case DBTYPE_VARIANT:
Vt = Colevariant (LPCVARIANT) Paccessor-> getValue (ncol));
Break;
Case DBTYPE_STR:
Str = (lpcstr) Paccessor-> getValue (ncol);
Break;
Case DBTYPE_WSTR:
Case DBTYPE_BSTR:
Str = (lpcwstr) Paccessor-> getValue (ncol);
Break;
Case DBTYPE_I1:
Case DBTYPE_UI1:
Lvalue = (long) (* (Byte *) Paccessor-> getValue (ncol)));
Break;
Case DBTYPE_I2:
Case DBTYPE_UI2:
Lvalue = (long) (* (short *) paccessor-> getValue (ncol)));
Break;
Case DBTYPE_I4:
Case DBTYPE_UI4:
Lvalue = (long) (* ((long *) paccessor-> getValue (ncol)));
Break;
Case DBTYPE_R4:
DVALUE = (Double) (* (Float *) Paccessor-> getValue (ncol)));
Break;
Case DBTYPE_R8:
DVALUE = * ((Double *) Paccessor-> getValue (ncol));
Break;
Case DBTYPE_NUMERIC:
{
DB_NUMERIC NUM;
IF (Paccessor-> GetValue (Ncol, & Num))
{
DVALUE = (Double) * ((__ tent64 *) Num.val);
While (Num.scale -> 0)
DVALUE / = 10;
IF (Num.Sign == 0)
DVALUE = -dvalue;
}
}
Break;
Case dbtype_varnumeric:
{
// MSDN has this part of the code, but there is a mistake, here is made
DVALUE = 0;
Unsigned long ncolumn = ncol;
DB_VARNUMERIC * PNUM;
Paccessor-> TranslateColumnno (NCOLUMN);
PNUM = (DB_VARNUMERIC *) Paccessor -> _ getDataPtr (ncolumn);
Ulong ulength = 0;
Paccessor-> getLength (Ncol, & ULENGTH);
INT PREC = (int) pNum-> precision;
INT scale = (int) pnum-> scale;
INT SIGN = (int) (pnum-> sigh> 0)? 1: -1; Byte Hi, LO;
Double Multiplier = 1;
Double Adjust = 1;
ULENGTH - = (SizeOf (dbtype_varnumeric) - 1);
For (ulong i = 0, j = 0; i { Hi = LO = PNUM-> VAL [i]; LO << = 4; Lo >> = 4; DVALUE = ((Ulong) LO) * MultiPlier; MultiPlier * = 16; Hi >> = 4; DVALUE = ((Ulong) Hi) * Multiplier; MultiPlier * = 16; } Adjust * = POW (10, scale) * Sign; DVALUE / = adjust; } Break; Case DBTYPE_DBDATE: { DBDATE DBDATE; IF (Paccessor-> getValue (ncol, & dbdate)) { CTIMETM (dbdate.year, dbdate.month, dbdate.day, 0, 0, 0); } } Break; Case DBTYPE_DBTIMESTAMP: { DBTimeStamp DBTimeStamp; IF (Paccessor-> getValue (ncol, & dbtimestamp)) { CTIMETM (dbtimestamp.year, dbtimestamp.month, dbtimestamp.day, DBTimeStamp. Hour, dbtimestamp.minute, dbtimestamp.second; Lvalue = tm.gettime (); } } Break; Case DBTYPE_DATE: { COLEDATETIME DT (* ((DATE *) Paccessor-> getValue (ncol))); Lvalue = dt.getyear () * 10000 dt.getmonth () * 10000 dt.getday (); } Break; Case DBTYPE_DBTIME: { DBTime dbtime; IF (Paccessor-> GetValue (ncol, & dbtime)) { Dt.SetTime (dbtime. Hour, dbtime.minute, dbtime.second); Vt = Colevariant (DT); } } Break; Case DBTYPE_CY: { Colecurrency Cy (* ((currentcy *) Paccessor-> getValue (ncol))))) Vt = Colevariant (CY); } Break; Case DBTYPE_IUNKNOWN: { ISEQUENTIALSTREAM * PSTREAM = * (ISEQUENTIALSTREAM **) Paccessor-> getValue (ncol); IF (PStream! = null) { CString Str; Unsigned long Lread = 0; Unsigned long loadthis = 0; CbyteArray aybytes; Byte Szbuffer [4096]; BYTE * PBYTE = NULL; DO { PStream-> Read (Szbuffer, 4096, & Lreadthis); IF (LreadThis> 0) { Aybytes.setsize (Lread LreadThis); PBYTE = aybetes.getdata (); Memcpy (Pbyte Lread, Szbuffer, LreadThis); Lread = Lreadthi; } } while (Lreadthis == 4096); Aybytes.setsize (LREAD); Vt = aybytes; } } Break; Case DBTYPE_NULL: Case DBTYPE_EMPTY: DEFAULT: Break; } }