Quote:
|
Is there a particular reason why we've chosen to set parameters of type Byte and Decimal to minValue instead of 0? Then why we didn't also set parameters of type Int16 to minValue ( instead we assigned them a value of 0 )?
|
In the case of Byte, it doesn't really make any difference, as the minvalue is in fact 0. For Decimal... honestly, I don't know. I agree it would have made more sense to set it to 0 for the sake of consistency.
Quote:
|
but he didn't check for other DbType values ( like DateTime2, sbyte, UInt16 etc -
|
Some of the enum members of DbType (such as DateTime2) didn't even exist at the time the book was written, since they only apply to SQL Server 2008, not 2005.
Quote:
|
When current context's user name is »sampleeditor«, ExecuteNonQuery returns 1. Is there a reason why method returns 1 and not some other number?
|
It returns 1 because that is how the provider methods indicate that a database operation was successful (i.e., that the method affected exactly one record):
int ret = ExecuteNonQuery(cmd);
return (ret == 1);
For a SampleEditor, the method returns 1, but does
not actually carry out the query. That way, a SampleEditor can use the application without actually altering the database. The ExecuteNonQuery in effect "fakes out" the application into believing these database operations have succeeded, when in fact they are not even being carried out.