Richard Ev
Richard Ev

Reputation: 54127

AddOutParameter - non-magic number way of finding length of DBType.Int32

I have a magic number in the following code...

Microsoft.Practices.EnterpriseLibrary.Data.Database db = /* code omitted */;

db.AddOutParameter(command, "@ParamName", DbType.Int32, 8);

Is there a clean way to get the length of DbType.Int32, as required for the last argument to AddOutParameter?

Upvotes: 6

Views: 6412

Answers (1)

Hans Olsson
Hans Olsson

Reputation: 55039

Not sure what you mean about length. It's a 32 bit int so it's 4 bytes which can be 10 digits as described in this quote from this MSDN page. An integral type representing signed 32-bit integers with values between -2147483648 and 2147483647.

I'm not sure hat specifying the size (the 8) for an int32 makes sense. For example, if it should map to an Oracle Number with a specified size of 8 it should probably be DbType.Decimal rather than Int32.

I'd suggest looking into just removing the 8 altogether since it's an output parameter I don't think it would affect anything.

Upvotes: 4

Related Questions