SqlParamater where type=SqlDbType.VarChar allows a size of -1!!!

  • Thread starter Thread starter BillDoorNZ
  • Start date Start date
B

BillDoorNZ

I've just finished writing some unit tests to test some SqlParameter
functions I created for a DAL helper class. I have included the base
version of the method below. One of the tests I wrote is a boundary
test and checks to make sure a size of -1 throw an
'ArgumentOutOfRange' exception. For some reason, it does
not....however, anything less than -1 does.

Does anyone know why?

BTW: I'm using .Net 2.0 and Ado.NET

public SqlParameter createStringParameter(string paramName,
int size)
{
SqlParameter result = new SqlParameter(paramName,
SqlDbType.VarChar);
result.Size = size;
result.Value = DBNull.Value;
return result;
}

Cheers,

Ed
 
Back
Top