I have the following line of code:
sqlcommand.Parameters.Add("@LinkID", SqlDbType.Int, 4).Value = linkID;
But, I'm slightly confused about the use of size
. Is this saying that its 4 bytes in size? Or a length of 4 so 1234
is acceptable but 12345
is too big?
For the types with fixes size you should omit this argument, simply:
The size argument is only relevant for parameters with a type that can have variable size like
varchar
,nvarchar
etc.The size is 4 bytes for an int.
See DbParameter class on msdn for more info. It is relevant because
SqlCeParameter
implementsDbParameter
The following section is relevant:
See this https://gist.github.com/1932766 for the implementation of the Size property.
if you are going for int than i think therre is no matter what size of it.
so you code will be
on for varchar,navarchar where the size is maater you need to speicify size in you .net code i.e in parameter
It is 4 bytes, 32 bits. It is a 32 bit integer.