|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
CADORecordBinding ... adDateI 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.
Show quote
"beginthreadex" wrote: I'm not familiar with RecordBinding, but ADO uses VARIANT's for the Value >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. 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
Show quote
>>I am using RecordBinding from VC++ successfully against a SQL server 2000 Thank you so very much! This is about the closest that I have seen to maybe>> 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. > > 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. 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. |
|||||||||||||||||||||||