SqlDbType sizes

G

Guest

Is there a table of sizes to use for SqlDbTypes with SqlParameter constructor
such as:
SqlParameter("@VanId", SqlDbType.Int, 4"));

Not sure which types require a size and which ones can be left blank.

Thanks
 
C

Christopher Reed

If the type is fixed, for example, an Int is 4 bytes, then you should leave
it out. Look at the MSDN documentation for more information.
 
G

Guest

Christopher, thanks for the tip. I have looked at the MSDN docs, the
SqlDbType doesn't mention sizes of enumerated types and the SqlParameter docs
doesn't give any advice about which data types require the constructor with
size parameter. Just trying to say I did some homework first ;)
 
K

Karl Seguin [MVP]

For the most part I only set the size when dealing with a char/nvarchar.

Karl
 
C

Christopher Reed

The best place to look is in the SQL Server documentation under Data Types.
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top