The data is truncated

  • Thread starter Thread starter Keld Laursen
  • Start date Start date
K

Keld Laursen

Might this be because the "nvarchar(40)" declaration declares a varchar(40)
array that can hold 40 8-bit characters, as opposed to 40 16-bit characters
(Unicode)?

IIRC, this is one of the differences between the varchar() and nvarchar()
data types.

HTH

Keld Laursen
 
Hello,

I have a table with a field defined as nvarchar(40).

When I am trying to post a value longer than 20 characters, SQLCE returns
the abouv error.

When I am using the sample string "12345678901234567890" and it works OK
(Len=20)
When I am using the sample string "123456789012345678901" and it works Fails
(Len=21)

I also tried dynamic SQL query and paramaterized query (also trying to
manually set SqlCeParameter.size=40)).
Both gave me the same result.

Any idea ?
 
Are you specifying the parameter type to be SqlDbType.NVarChar? The peculiar
difference between your two strings is that the first one is an integer that
fits a 64-bit representation, while the second one does not (it exceeds
2^64-1). It looks almost like your strings are getting converted to bigint
somewhere. Also, what exactly is "above error"? I don;t think you included
the error message in your post
 
Back
Top