Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2008

    Unhappy Unanswered: VB6 ADO SQL2005 sdDecimal

    I am using ADO in VB6 to call a stored procedure in SQL2005. The stored procedure is looking for data as "decimal(6,5)". My data is a double in VB6. In VB6, I tried setting up the call as follows (This is right out of an ADO book):

    SQLCommand.Parameters.Append .CreateParameter("@Offset", adDecimal, adParamInput, , CalibrationEEPROM(Unit).offset)
    SQLCommand.Parameters("@Offset").Precision = 6
    SQLCommand.Parameters("@Offset").NumericScale = 5

    After doing a trace, the number I passed -0.03125 is converted in the trace to -312.

    In another forum, they told me that this is because NumericScale and Precision are enumerated types correspond to adDouble and adCurrency.

    I don't know which is correct. The way ADO converted the data it sent to SQL, I'd assume that the enumerated explanation is correct. If that's true, how can I get it to be sent to SQL correctly?

  2. #2
    Join Date
    Nov 2008

    ADO Type Conversion

    Here is a table that is a big help for me. Keep in mind that Decimal and Numeric report to ADO as the same but not to SQL.
    #	Chr	SQL	ADOType 	ADO Description
    20	20	bigint	adBigInt	Eight-byte signed integer (DBTYPE_I8).
    128	128	binary	adBinary	Binary value (DBTYPE_BYTES).
    11	11	bit	adBoolean	Boolean value (DBTYPE_BOOL).
    8	8	adBSTR	Null-terminated character String (Unicode) (DBTYPE_BSTR).
    136	136	adChapter	Four-byte chapter value that identifies rows in a child rowset (DBTYPE_HCHAPTER).
    129	129	Char, VarChar, Text	adChar	String value (DBTYPE_STR).
    6	6	Money	adCurrency	Currency value (DBTYPE_CY). Currency is a fixed-point number with four digits to the right of the decimal point. It is stored in an eight-byte signed integer scaled by 10,000.
    7	7	datetime	adDate	Date Value (DBTYPE_DATE). A date is stored as a double, the whole part of which is the number of days since December 30, 1899, and the fractional part of which is the fraction of a day.
    133	133	adDBDate	Date Value (yyyymmdd) (DBTYPE_DBDATE).
    134	134	adDBTime	Time value (hhmmss) (DBTYPE_DBTIME).
    135	135	Datetime	adDBTimeStamp	Date/time stamp (yyyymmddhhmmss plus a fraction in billionths) (DBTYPE_DBTIMESTAMP).
    14	14	Decimal	adDecimal	Exact numeric value with a fixed precision and scale (DBTYPE_DECIMAL).
    5	5	float	adDouble	Double-precision floating-point value (DBTYPE_R8).
    0	0		adEmpty	Specifies no value (DBTYPE_EMPTY).
    10	10		adError	32-bit error code (DBTYPE_ERROR).
    64	64		adFileTime	64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (DBTYPE_FILETIME).
    72	72		adGUID	Globally unique identifier (GUID) (DBTYPE_GUID).
    9	9		adIDispatch	Pointer to an IDispatch interface on a COM object (DBTYPE_IDISPATCH). Note***This data type is currently not supported by ADO. Usage may cause unpredictable results.
    3	3	int	adInteger	Four-byte signed integer (DBTYPE_I4).
    13	13		adIUnknown	Pointer to an IUnknown interface on a COM object (DBTYPE_IUNKNOWN). Note ***This data type is currently not supported by ADO. Usage may cause unpredictable results.
    205	205		adLongVarBinary	Long binary value.
    201	201		adLongVarChar	Long String value.
    203	203		adLongVarWChar	Long Null-terminated Unicode String value.
    131	131	decimal	adNumeric	Exact numeric value with a fixed precision and scale (DBTYPE_NUMERIC).
    138	138		adPropVariant	Automation PROPVARIANT (DBTYPE_PROP_VARIANT).
    4	4		adSingle	Single-precision floating-point value (DBTYPE_R4).
    2	2	smallint	adSmallInt	Two-byte signed integer (DBTYPE_I2).
    16	16		adTinyInt	One-byte signed integer (DBTYPE_I1).
    21	21		adUnsignedBigInt	Eight-byte unsigned integer (DBTYPE_UI8).
    19	19		adUnsignedInt	Four-byte unsigned integer (DBTYPE_UI4).
    18	18		adUnsignedSmallInt	Two-byte unsigned integer (DBTYPE_UI2).
    17	17		adUnsignedTinyInt	One-byte unsigned integer (DBTYPE_UI1).
    132	132		adUserDefined	User-defined variable (DBTYPE_UDT).
    204	204	Image, Varbinary	adVarBinary	Binary value.
    200	200		adVarChar	String value.
    12	12	sql_variant	adVariant	Automation Variant (DBTYPE_VARIANT). Note ***This data type is currently not supported by ADO. Usage may cause unpredictable results.
    139	139		adVarNumeric	Numeric value.
    202	202		adVarWChar	Null-terminated Unicode character String.
    130	130	nvarchar	adWChar	Null-terminated Unicode character String (DBTYPE_WSTR).
    	0x2000		AdArray	A flag value, always combined with another data type constant, that  array of the other data type. Does not apply to ADOX.
    Last edited by loquin; 12-11-08 at 14:46. Reason: add [code] [/code] tags around the table to avoid html mucking about with the tabs/spaces..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts