Annoying parameters and exceptions
There are some small annoying discrepancies in the .net
framework. Some are real, and some are just due to my lack of understanding of
the genious of the designers who made it this way.
Today my annoyance was created by the IDbCommand object's Parameters
collection. Whilst both the OleDbCommand.Parameters.Add() and
SqlCommand.Parameters.Add() returns the parameter added the
IDbCommand.Parameters.Add() doesn't return an IDbParameter but an int indicating
the index. Why is this annoying? Simply because it makes it impossible to write
a parameter addition on one line like this:
IDbCommandObject.Paremeters.Add(new IDbParameter("@param",
DbType.Int64)).Value = myLong;
Another question mark is why SqlException and OleDbException have no common
baseclass or interface other than System.SystemException. One might think that
System.Data.DataException catches these but that one is just for plain ADO.NET
exceptions, not providerexceptions.
If there is a good reason for these things I'll be glad to add this to the pile of
genious .net framework design choices.