Specifying parameter sizes

Topics: Data Access Application Block
Jan 22, 2008 at 8:35 AM
Hi all,

I've just started using entlib 3.1 and the DAAB. I've noticed that when adding in parameters to a command using the Database class there is no way to specify the size of the data. Doesn't ADO.NET need this information?

For example, when passing a timestamp to an SP I am using a DBType of Binary and the 'object' I pass is a byte8. How does it know that the size of the binary data I'm giving it should be 8 bytes? Similarly when passing DBType.String, how does it know what the length of the string should be.

Forgive the simple questions but regular ADO.NET and SqlParameters requires this information, why doesn't the DAAB?
Jan 22, 2008 at 7:11 PM

You can add parameters with any of the AddParameter overrides for class Database, supplying the appropriate parameter information like size, type, db type, precision, scale, etc.
You won't be able to take advantage of this if you're using the utility methods that just take the parameters' values, but you can always tune your command with the lower level methods.

Jan 23, 2008 at 10:33 AM
Edited Jan 23, 2008 at 10:34 AM
Do I actually need to specify sizes for in parameters? What are the advantages in doing so?