ADODB Parameters: work independent from regional formats

Armin Zingler 0 Reputation points
2024-11-14T08:26:00.6266667+00:00

Hi,

I'm using an ADODB.Command object and it's Parameters property to insert records into an Access database ("insert into table (...) values (...)"). One of the table fields is of type Currency. The corresponding ADODB.Parameter.Type is DataTypeEnum.adCurrency.

The advantage of using parameters is that we don't have to care about regional settings (number and date formats). However, in this case, I get wrong values in the table.

Dim hours As Currency
'...
cmd.Parameters.Item(8).Value = hours     'hours is 123.45
'...
cmd.Execute

Result: The field contains 12345. I expect 123.45.

The same issue with dates: Our (german) regional format ist dd.MM.yyyy. If the parameter value is 2/1/2024 (first of February), the table contains the value 1/2/2024 (second of January).

Question: Why?? Can I change this behavior? Is my assumption wrong, that the behavior is independent from regional settings? Obviously it's not. This is new to me.

(unfortunatelly I found none of the tags like ADODB, database programming (in general), VBA, Jet Engine, oledb)

Excel
Excel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
1,982 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,012 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.