Dec 19 2022 11:46 PM
I am running a C# App and trying to run a query, but it is failing with the following error:
"`The fractional part of the provided time value overflows the scale of the corresponding SQL Server parameter or column. Increase bScale in DBPARAMBINDINFO or column scale to correct this error."
The column in question is of type '[datetime2](0)'. This was working with 'SQLOLEDB.1' but failing with 'MSOLEDBSQL19.1'.
Table Schema:
CREATE TABLE [dbo].[TEST_TABLE ](
[ID] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
[COL1] [varchar](50) NOT NULL,
[COL2] [varchar](500) NOT NULL,
[Date] [datetime2](0) NULL)
I have already tried adding the parameter "DateTypeCompatibility=80;DateTimeFormat=\"dd-mm-yyyy hh:mm:ss.fffffff\"" to connection string.
I have also tried SQL Native Client Driver 10/11 as well.
Edit:
Tried: datetime2 type instead of datetime2(0)
Tried: datetime2(7) type instead of datetime2(0)
What could be a solution to this? My requirement is not to change the code, but to make change in either DB or connection string.
I tried a code change -> new OleDbParameter("?", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.fffffff")) which does work but code change
may not be possible for some reason.