Groups | Blog | Home
all groups > sql server programming > november 2005 >

sql server programming : CADORecordBinding ... adDate


beginthreadex
11/10/2005 9:09:14 PM
I am using RecordBinding from VC++ successfully against a SQL server 2000
database. My issues revolve around getting datetimes from SQL into anything
readable in VC++ as a date/double/ULARGE??? variable. Right now I can put
this data into a double but the data is not able to be parsed. There does
not seem to be a clean conversion from double to a FILETIME or other
struct.

How can I use CADORecordBinding and get a "getdate()" value from SQL without
converting to a varchar(x)?

The sample in MSDN states using a DBDATE variable, but there's no success
with this. It also states that you should use ADO_FIXED in one sample and
then another is ADO_VARIABLE ... so I'm really confused and would really
welcome a solution at this point.

Craig Kelly
11/10/2005 10:39:35 PM
[quoted text, click to view]

I'm not familiar with RecordBinding, but ADO uses VARIANT's for the Value
property in a Recordset.Fields.Item(blah).Value expression. And, if you're
using ADO via the #import directive, it's a _variant_t. I typically use
something like:

void get_date(_variant_t& v, SYSTEMTIME& st)
{
memset(&st, 0, sizeof(st));
_variant_t d(v);
d.ChangeType(VT_DATE);
VARIANT vr = d.Detach();
VariantTimeToSystemTime(vr.date, &st);
VariantClear(&vr);
}

Of course, error checking, good variable names, etc have been left out to
make my posting easier :)

If you don't use the _variant_t compiler helper type, note that the
important function is VariantTimeToSystemTime: this is a standard automation
function supplied by oleaut32.

Craig

beginthreadex
11/10/2005 11:04:16 PM
[quoted text, click to view]

Thank you so very much! This is about the closest that I have seen to maybe
being an answer. Let me see where this takes me.

There is simply NOTHING faster than RecordBinding when using ADO. You create
a class of your C primatives as a recordset representative and bind that to
the recordset. When you do the binding ADO will swap out it's internal
variables for field values with yours. So you do not go through the Fields
collection and there is no BSTR conversion and all the other marshaling.
It's just SO SO SO fast. It's clearly documented for but dates seems to
have slipped by the MS documentation persons.

Thanks again! If you have more information, let me know.
AddThis Social Bookmark Button