The data is truncated

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
 
O

oren

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 ?
 
A

Alex Feinman [MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top