SQL-DMO Data Types
Type definitions included in Sqldmo.h, or in header files on which Sqldmo.h depends, provide the application with types defined by the Microsoft® Platform SDK. With the exception of OLE date data type handling, there is nothing unique about SQL-DMO data types.
For the C/C++ developer, SQL-DMO does not directly support a data type exposing a date and/or time value. Object properties returning an OLE date data type to an application developed using an OLE Automation controller will, instead, return a packed long integer to the C/C++ application.
For example, the LastOccurrenceDate property of the Alert object exposes a date value to a Microsoft Visual Basic®/ActiveX® script application. The Alert object member functions implementing LastOccurrenceDate are GetLastOccurrenceDate and SetLastOccurrenceDate with the following prototypes:
HRESULT GetLastOccurrenceDate(LPLONG pRetVal);
HRESULT SetLastOccurrenceDate(long NewValue);
SQL-DMO does not specify a function argument type wide enough to capture the precision expressed in an OLE date. Instead, the member functions extract and set only the date portion of a date and time value.
For C/C++, SQL-DMO addresses the date/time data type width problem by implementing a group of member functions. One member function pair extracts the date portion of the property value and a second extracts the time portion. For read/write properties, a second function pair implements setting the date value.
When SQL-DMO uses a scaled long integer to represent a date, the integer is built as a sum of the year scaled by 10000, the month scaled by 100, and the day. For example, the date April 19, 1997 is represented by the long integer value 19970419.
When SQL-DMO uses a scaled long integer to represent a time, the integer is built as a sum of the hour scaled by 10000, the minute scaled by 100, and the seconds. The time value uses a 24-hour clock. For example, the time 1:03:09 P.M. is represented by the long integer value 130309.