OdbcDataAdapter.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. //
  2. // System.Data.Odbc.OdbcDataAdapter.cs
  3. //
  4. // Author:
  5. // Rodrigo Moya ([email protected])
  6. // Daniel Morgan ([email protected])
  7. // Tim Coleman ([email protected])
  8. //
  9. // (C) Ximian, Inc 2002
  10. // Copyright (C) 2002 Tim Coleman
  11. //
  12. //
  13. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  14. //
  15. // Permission is hereby granted, free of charge, to any person obtaining
  16. // a copy of this software and associated documentation files (the
  17. // "Software"), to deal in the Software without restriction, including
  18. // without limitation the rights to use, copy, modify, merge, publish,
  19. // distribute, sublicense, and/or sell copies of the Software, and to
  20. // permit persons to whom the Software is furnished to do so, subject to
  21. // the following conditions:
  22. //
  23. // The above copyright notice and this permission notice shall be
  24. // included in all copies or substantial portions of the Software.
  25. //
  26. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  27. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  28. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  29. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  30. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  31. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  32. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  33. //
  34. using System;
  35. using System.ComponentModel;
  36. using System.Data;
  37. using System.Data.Common;
  38. namespace System.Data.Odbc
  39. {
  40. [DefaultEvent ("RowUpdated")]
  41. [DesignerAttribute ("Microsoft.VSDesigner.Data.VS.OdbcDataAdapterDesigner, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.ComponentModel.Design.IDesigner")]
  42. [ToolboxItemAttribute ("Microsoft.VSDesigner.Data.VS.OdbcDataAdapterToolboxItem, "+ Consts.AssemblyMicrosoft_VSDesigner)]
  43. public sealed class OdbcDataAdapter : DbDataAdapter, IDbDataAdapter, ICloneable
  44. {
  45. #region Fields
  46. #if ONLY_1_1
  47. bool disposed;
  48. #endif
  49. OdbcCommand deleteCommand;
  50. OdbcCommand insertCommand;
  51. OdbcCommand selectCommand;
  52. OdbcCommand updateCommand;
  53. #endregion
  54. #region Constructors
  55. public OdbcDataAdapter () : this ((OdbcCommand) null)
  56. {
  57. }
  58. public OdbcDataAdapter (OdbcCommand selectCommand)
  59. {
  60. SelectCommand = selectCommand;
  61. }
  62. public OdbcDataAdapter (string selectCommandText, OdbcConnection selectConnection)
  63. : this (new OdbcCommand (selectCommandText, selectConnection))
  64. {
  65. }
  66. public OdbcDataAdapter (string selectCommandText, string selectConnectionString)
  67. : this (selectCommandText, new OdbcConnection (selectConnectionString))
  68. {
  69. }
  70. #endregion
  71. #region Properties
  72. [OdbcCategory ("Update")]
  73. [OdbcDescription ("Used during Update for deleted rows in DataSet.")]
  74. [DefaultValue (null)]
  75. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
  76. public new OdbcCommand DeleteCommand {
  77. get { return deleteCommand; }
  78. set { deleteCommand = value; }
  79. }
  80. [OdbcCategory ("Update")]
  81. [OdbcDescription ("Used during Update for new rows in DataSet.")]
  82. [DefaultValue (null)]
  83. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
  84. public new OdbcCommand InsertCommand {
  85. get { return insertCommand; }
  86. set { insertCommand = value; }
  87. }
  88. [OdbcCategory ("Fill")]
  89. [OdbcDescription ("Used during Fill/FillSchema.")]
  90. [DefaultValue (null)]
  91. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
  92. public new OdbcCommand SelectCommand {
  93. get { return selectCommand; }
  94. set { selectCommand = value; }
  95. }
  96. [OdbcCategory ("Update")]
  97. [OdbcDescription ("Used during Update for modified rows in DataSet.")]
  98. [DefaultValue (null)]
  99. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
  100. public new OdbcCommand UpdateCommand {
  101. get { return updateCommand; }
  102. set { updateCommand = value; }
  103. }
  104. IDbCommand IDbDataAdapter.DeleteCommand {
  105. get { return DeleteCommand; }
  106. set { DeleteCommand = (OdbcCommand) value; }
  107. }
  108. IDbCommand IDbDataAdapter.InsertCommand {
  109. get { return InsertCommand; }
  110. set { InsertCommand = (OdbcCommand) value; }
  111. }
  112. IDbCommand IDbDataAdapter.SelectCommand {
  113. get { return SelectCommand; }
  114. set { SelectCommand = (OdbcCommand) value; }
  115. }
  116. IDbCommand IDbDataAdapter.UpdateCommand {
  117. get { return UpdateCommand; }
  118. set { UpdateCommand = (OdbcCommand) value; }
  119. }
  120. #endregion // Properties
  121. #region Methods
  122. protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
  123. {
  124. return new OdbcRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
  125. }
  126. protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
  127. {
  128. return new OdbcRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
  129. }
  130. #if ONLY_1_1
  131. protected override void Dispose (bool disposing)
  132. {
  133. if (!disposed) {
  134. if (disposing) {
  135. // Release managed resources
  136. }
  137. // Release unmanaged resources
  138. disposed = true;
  139. }
  140. base.Dispose (true);
  141. }
  142. #endif
  143. protected override void OnRowUpdated (RowUpdatedEventArgs value)
  144. {
  145. if (RowUpdated != null)
  146. RowUpdated (this, (OdbcRowUpdatedEventArgs) value);
  147. }
  148. protected override void OnRowUpdating (RowUpdatingEventArgs value)
  149. {
  150. if (RowUpdating != null)
  151. RowUpdating (this, (OdbcRowUpdatingEventArgs) value);
  152. }
  153. [MonoTODO]
  154. object ICloneable.Clone ()
  155. {
  156. throw new NotImplementedException ();
  157. }
  158. #endregion // Methods
  159. #region Events and Delegates
  160. public event OdbcRowUpdatedEventHandler RowUpdated;
  161. public event OdbcRowUpdatingEventHandler RowUpdating;
  162. #endregion // Events and Delegates
  163. }
  164. }