There are other questions with similar sounding titles, but my case appears to be unique, so here goes:
This problem seems to be centered on using Decimal values in my table. If I create a table and leave out the Precision and Scale parameters, the table creates but all of my data is inserted as an integer value. If I create a table and specify the Precision and Scale parameters, I get the exception thrown below my SQL Statements.
Here is my Create Table statement:
CREATE TABLE RMCoil
(
ID int IDENTITY (100,1) PRIMARY KEY
, Modified DateTime NOT NULL
, [Type] nchar(1)
, [Model] nvarchar(50)
, [CPPartNo] nvarchar(50)
, [FH] decimal(10,10)
, [FL] decimal(10,10)
, [FPI] int
, [TR] nchar(1)
, [FinThk] decimal(10,10)
, [FinMat] nchar(1)
, [TubeOD] int
, [Rifled] nchar(1)
, [WallThk] decimal(10,10)
, [CKT] int
, [RD] int
, [Split] nvarchar(50)
, [CKT1] int
, [CKT2] int
, [CKT3] int
, [CKT4] int
, [Feed1] int
, [Feed2] int
, [Feed3] int
, [Feed4] int
, [Altitude] decimal(10,10)
, [Connection] decimal(10,10)
, [Header] decimal(10,10)
)
SqlCeCommand.ExecuteNonQuery() returns -1, but this must be OK because it creates the table.
If a table exists, the SELECT statement works fine:
SELECT
ID
, Modified
, [ID]
, [MODIFIED]
, [Model]
, [VoltCode]
, [Vendor]
, [Product]
, [ACRLA208SP]
, [LRA208SP]
, [ACRLA230SP]
, [LRA230SP]
, [ACRLA208]
, [LRA208]
, [ACRLA230]
, [LRA230]
, [ACRLA380]
, [LRA380]
, [ACRLA460]
, [LRA460]
, [ACRLA575]
, [LRA575]
, [ECRLA208]
, [ECRLA230]
, [ECRLA460]
, [ECRLA575]
, [Displacement]
, [CF0]
, [CF1]
, [CF2]
, [CF3]
, [CF4]
, [CF5]
, [CF6]
, [CF7]
, [CF8]
, [CF9]
, [CF10]
, [CF11]
, [CF12]
, [CF13]
, [CF14]
, [CF15]
, [CF16]
, [CF17]
, [CF18]
, [CF19]
, [CF20]
, [CF21]
, [CF22]
, [CF23]
, [CF24]
, [CF25]
, [CF26]
, [CF27]
, [CF28]
, [CF29]
, [CF30]
, [CF31]
, [CF32]
, [CF33]
, [CF34]
, [CF35]
, [CF36]
, [CF37]
, [CF38]
, [CF39]
FROM RMCompressor
SqlCeCommand.CommandText.Length = 633
INSERT INTO RMCompressor
(
Modified
, [Model]
, [VoltCode]
, [Vendor]
, [Product]
, [ACRLA208SP]
, [LRA208SP]
, [ACRLA230SP]
, [LRA230SP]
, [ACRLA208]
, [LRA208]
, [ACRLA230]
, [LRA230]
, [ACRLA380]
, [LRA380]
, [ACRLA460]
, [LRA460]
, [ACRLA575]
, [LRA575]
, [ECRLA208]
, [ECRLA230]
, [ECRLA460]
, [ECRLA575]
, [Displacement]
, [CF0]
, [CF1]
, [CF2]
, [CF3]
, [CF4]
, [CF5]
, [CF6]
, [CF7]
, [CF8]
, [CF9]
, [CF10]
, [CF11]
, [CF12]
, [CF13]
, [CF14]
, [CF15]
, [CF16]
, [CF17]
, [CF18]
, [CF19]
, [CF20]
, [CF21]
, [CF22]
, [CF23]
, [CF24]
, [CF25]
, [CF26]
, [CF27]
, [CF28]
, [CF29]
, [CF30]
, [CF31]
, [CF32]
, [CF33]
, [CF34]
, [CF35]
, [CF36]
, [CF37]
, [CF38]
, [CF39])
VALUES
(
GetDate()
, @Model
, @VoltCode
, @Vendor
, @Product
, @ACRLA208SP
, @LRA208SP
, @ACRLA230SP
, @LRA230SP
, @ACRLA208
, @LRA208
, @ACRLA230
, @LRA230
, @ACRLA380
, @LRA380
, @ACRLA460
, @LRA460
, @ACRLA575
, @LRA575
, @ECRLA208
, @ECRLA230
, @ECRLA460
, @ECRLA575
, @Displacement
, @CF0
, @CF1
, @CF2
, @CF3
, @CF4
, @CF5
, @CF6
, @CF7
, @CF8
, @CF9
, @CF10
, @CF11
, @CF12
, @CF13
, @CF14
, @CF15
, @CF16
, @CF17
, @CF18
, @CF19
, @CF20
, @CF21
, @CF22
, @CF23
, @CF24
, @CF25
, @CF26
, @CF27
, @CF28
, @CF29
, @CF30
, @CF31
, @CF32
, @CF33
, @CF34
, @CF35
, @CF36
, @CF37
, @CF38
, @CF39
)
SqlCeException: Expression evaluation caused an overflow. [ Name of function (if known) = ]
HResult: -2147217900
NativeError: 25901
Source: SQL Server Compact ADO.NET Data Provider
Does anyone know how to read th开发者_运维知识库e HResult or NativeError?
My INSERT statement isn't too long or something, is it?
If it helps, I've uploaded my Visual Studio 2010 C# project SqlCeTool (without the binaries) >> HERE << (I will remove my project link after this issue is resolved).
You are creating a decimal values with equal precision and scale, is that intended? As it stands, you are creating fields like Altitude which can contain values of .0000000000 to .9999999999 (assuming I counted right). I believe you will want to adjust your precision and scale to be something like Altitude(20,10)
Books On Line article discussing Precision, Scale, and Length Money quote: "Precision is the number of digits in a number. Scale is the number of digits to the right of the decimal point in a number. For example, the number 123.45 has a precision of 5 and a scale of 2."
精彩评论