How to use Prepare?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,

when using Prepare() on a SqlCommand, the SqlClient (unlike the
OracleClient) requires for certain types, that Size, Precision and/or
Scale have been set *explicitly* by the user.

The problem I have is, that I don't know in advance what values should be
stored.

So my approach is, to set the maximal value (e.g. 4000 for size for
DbType.String).

My questions are:
Does that matter at all when executing the Command?
If I specify 4000 but the string is just 3 characters long, would it have
been faster (or consume less memory) if I had specified some smaller value
instead of 4000?
What happens if my string exceeds 4000 characters?

Thank you in advance!

Christian
.



Relevant Pages