I have a method that either adds or updates a record in the database (SQL Server), and returns the RecordID as the output parameter (Int32), as well as the success / failure result as (Int32). Return value
Given that I indicate the type of these parameters, why should I drop them when they return?
I expected to use the following:
enquiryID = cmd.Parameters["@EnquiryID"].Value;
... but I and I have to jump through a couple of extra hoops:
enquiryID = Int32.Parse(cmd.Parameters["@EnquiryID"].Value.ToString());
This is not the end of the world, but it just looks like a long-term solution. Why does Parameters.Value return an SqlParameters.Value rather than Int32?
UPDATE:
OK, I am convinced - FTW direct casting: (int)cmd.Parameters["@EnquiryID"].Value