public IBaseProps Create(IBaseProps p) { int rowsAffected = 0; CustomerProp props = (CustomerProp)p; DBCommand command = new DBCommand(); command.CommandText = "usp_CustomerCreate"; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@CustomerID", SqlDbType.Int); command.Parameters.Add("@Name", SqlDbType.VarChar); command.Parameters.Add("@Address", SqlDbType.VarChar); command.Parameters.Add("@City", SqlDbType.VarChar); command.Parameters.Add("@State", SqlDbType.Char); command.Parameters.Add("@ZipCode", SqlDbType.Char); command.Parameters.Add("@ConcurrencyID", SqlDbType.Int); command.Parameters[0].Direction = ParameterDirection.Output; command.Parameters["@CustomerID"].Value = props.ID; command.Parameters["@Name"].Value = props.Name; command.Parameters["@Address"].Value = props.Address; command.Parameters["@City"].Value = props.City; command.Parameters["@State"].Value = props.State; command.Parameters["@ZipCode"].Value = props.Zipcode; command.Parameters["@ConcurrencyID"].Value = props.ConcurrencyID; try { rowsAffected = RunNonQueryProcedure(command); if (rowsAffected == 1) { props.ID = (int)command.Parameters[0].Value; props.ConcurrencyID = 1; return(props); } else { throw new Exception("Unable to insert record. " + props.ToString()); } } catch (Exception e) { // log this error throw; } finally { if (mConnection.State == ConnectionState.Open) { mConnection.Close(); } } }