SqlDbType sizes

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
 
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 ;)
 
For the most part I only set the size when dealing with a char/nvarchar.

Karl
 
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

Back
Top