What to put in for size when adding a parameter

S

Sam

When you're adding parameters to a sqlcommand, what do you put in for
the size value? I need to put in the size because this is the only
overload with sourceColumn and I need that.

This is what I have corresponding to the types

'size=10, since Int is max of 10 digits
MyCommand.Parameters.Add("@MyInt", SqlDbType.Int, 10, "MyInt")

'size=19, since BigInt is max of 19 digits
MyCommand.Parameters.Add("@MyBigInt", SqlDbType.BigInt, 19,
"MyBigInt")

'size=4, since MyString is length 4
MyCommand.Parameters.Add("@MyString", SqlDbType.Char, 4, "MyString")

Is this correct?

Thanks...
 
T

Tu-Thach

That probably is correct. Note that for fixed width data
types, the value of Size is ignored. So, for int, long,
etc. the Size does not matter.

Tu-Thach
 

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