Questions That Should Be Asked More Frequently

Q

How can I determine the values of the SqlDbType, Length, Scale, and Precision properties for a SqlParameter that matches up with a column in my table.

A

There are a couple simple ways to determine this information. The easiest way to check these properties for your column is to select the column in the Server Explorer window and check the Data Type, Length, Scale, and Precision properties in the Properties window. You can also create a SqlCommand to query for that column, call ExecuteReader with a CommandBehavior of SchemaOnly so that the SqlDataReader you receive contains only schema, no results. Then call GetSchemaTable and check the values of the SqlDbType, Length, Scale, and Precision properties ...

Get Programming Microsoft® ADO.NET 2.0 Core Reference, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.