SqlParameterCollection.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //
  2. // System.Data.Common.SqlParameterCollection
  3. //
  4. // Author:
  5. // Boris Kirzner ([email protected])
  6. //
  7. /*
  8. * Copyright (c) 2002-2004 Mainsoft Corporation.
  9. *
  10. * Permission is hereby granted, free of charge, to any person obtaining a
  11. * copy of this software and associated documentation files (the "Software"),
  12. * to deal in the Software without restriction, including without limitation
  13. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  14. * and/or sell copies of the Software, and to permit persons to whom the
  15. * Software is furnished to do so, subject to the following conditions:
  16. *
  17. * The above copyright notice and this permission notice shall be included in
  18. * all copies or substantial portions of the Software.
  19. *
  20. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  23. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  26. * DEALINGS IN THE SOFTWARE.
  27. */
  28. using System.Data.ProviderBase;
  29. namespace System.Data.SqlClient
  30. {
  31. public class SqlParameterCollection : AbstractDbParameterCollection
  32. {
  33. #region Constructors
  34. public SqlParameterCollection(SqlCommand parent): base(parent)
  35. {
  36. }
  37. #endregion // Constructors
  38. #region Properties
  39. public SqlParameter this[string parameterName]
  40. {
  41. get { return (SqlParameter)base[parameterName]; }
  42. set {
  43. OnSchemaChanging();
  44. base[parameterName] = value;
  45. }
  46. }
  47. public SqlParameter this[int index]
  48. {
  49. get { return (SqlParameter)base[index]; }
  50. set {
  51. base.OnSchemaChanging();
  52. base[index] = value;
  53. }
  54. }
  55. protected override Type ItemType {
  56. get { return typeof(SqlParameter); }
  57. }
  58. #endregion // Properties
  59. #region Methods
  60. public SqlParameter Add(SqlParameter value)
  61. {
  62. base.Add(value);
  63. return value;
  64. }
  65. public SqlParameter Add(string parameterName, object value)
  66. {
  67. SqlParameter param = new SqlParameter(parameterName,value);
  68. return Add(param);
  69. }
  70. public SqlParameter Add(string parameterName, SqlDbType sqlDbType)
  71. {
  72. SqlParameter param = new SqlParameter(parameterName,sqlDbType);
  73. return Add(param);
  74. }
  75. public SqlParameter Add(string parameterName, SqlDbType sqlDbType, int size)
  76. {
  77. SqlParameter param = new SqlParameter(parameterName,sqlDbType,size);
  78. return Add(param);
  79. }
  80. public SqlParameter Add(string parameterName, SqlDbType sqlDbType, int size, string sourceColumn)
  81. {
  82. SqlParameter param = new SqlParameter(parameterName,sqlDbType,size,sourceColumn);
  83. return Add(param);
  84. }
  85. #endregion // Methods
  86. }
  87. }