OdbcDataAdapter.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. [DefaultEvent ("RowUpdated")]
  40. [DesignerAttribute ("Microsoft.VSDesigner.Data.VS.OdbcDataAdapterDesigner, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.ComponentModel.Design.IDesigner")]
  41. [ToolboxItemAttribute ("Microsoft.VSDesigner.Data.VS.OdbcDataAdapterToolboxItem, "+ Consts.AssemblyMicrosoft_VSDesigner)]
  42. public sealed class OdbcDataAdapter : DbDataAdapter, IDbDataAdapter, ICloneable
  43. {
  44. #region Fields
  45. #if ONLY_1_1
  46. bool disposed;
  47. #endif
  48. OdbcCommand deleteCommand;
  49. OdbcCommand insertCommand;
  50. OdbcCommand selectCommand;
  51. OdbcCommand updateCommand;
  52. #endregion
  53. #region Constructors
  54. public OdbcDataAdapter () : this ((OdbcCommand) null)
  55. {
  56. }
  57. public OdbcDataAdapter (OdbcCommand selectCommand)
  58. {
  59. SelectCommand = selectCommand;
  60. }
  61. public OdbcDataAdapter (string selectCommandText, OdbcConnection selectConnection)
  62. : this (new OdbcCommand (selectCommandText, selectConnection))
  63. {
  64. }
  65. public OdbcDataAdapter (string selectCommandText, string selectConnectionString)
  66. : this (selectCommandText, new OdbcConnection (selectConnectionString))
  67. {
  68. }
  69. #endregion
  70. #region Properties
  71. [OdbcCategory ("Update")]
  72. [OdbcDescription ("Used during Update for deleted rows in DataSet.")]
  73. [DefaultValue (null)]
  74. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
  75. public new OdbcCommand DeleteCommand {
  76. get { return deleteCommand; }
  77. set { deleteCommand = value; }
  78. }
  79. [OdbcCategory ("Update")]
  80. [OdbcDescription ("Used during Update for new rows in DataSet.")]
  81. [DefaultValue (null)]
  82. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
  83. public new OdbcCommand InsertCommand {
  84. get { return insertCommand; }
  85. set { insertCommand = value; }
  86. }
  87. [OdbcCategory ("Fill")]
  88. [OdbcDescription ("Used during Fill/FillSchema.")]
  89. [DefaultValue (null)]
  90. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
  91. public new OdbcCommand SelectCommand {
  92. get { return selectCommand; }
  93. set { selectCommand = value; }
  94. }
  95. [OdbcCategory ("Update")]
  96. [OdbcDescription ("Used during Update for modified rows in DataSet.")]
  97. [DefaultValue (null)]
  98. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
  99. public new OdbcCommand UpdateCommand {
  100. get { return updateCommand; }
  101. set { updateCommand = value; }
  102. }
  103. IDbCommand IDbDataAdapter.DeleteCommand {
  104. get { return DeleteCommand; }
  105. set { DeleteCommand = (OdbcCommand) value; }
  106. }
  107. IDbCommand IDbDataAdapter.InsertCommand {
  108. get { return InsertCommand; }
  109. set { InsertCommand = (OdbcCommand) value; }
  110. }
  111. IDbCommand IDbDataAdapter.SelectCommand {
  112. get { return SelectCommand; }
  113. set { SelectCommand = (OdbcCommand) value; }
  114. }
  115. IDbCommand IDbDataAdapter.UpdateCommand {
  116. get { return UpdateCommand; }
  117. set { UpdateCommand = (OdbcCommand) value; }
  118. }
  119. ITableMappingCollection IDataAdapter.TableMappings {
  120. get { return TableMappings; }
  121. }
  122. #endregion // Properties
  123. #region Methods
  124. protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
  125. {
  126. return new OdbcRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
  127. }
  128. protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
  129. {
  130. return new OdbcRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
  131. }
  132. #if ONLY_1_1
  133. protected override void Dispose (bool disposing)
  134. {
  135. if (!disposed) {
  136. if (disposing) {
  137. // Release managed resources
  138. }
  139. // Release unmanaged resources
  140. disposed = true;
  141. }
  142. base.Dispose (true);
  143. }
  144. #endif
  145. protected override void OnRowUpdated (RowUpdatedEventArgs value)
  146. {
  147. if (RowUpdated != null)
  148. RowUpdated (this, (OdbcRowUpdatedEventArgs) value);
  149. }
  150. protected override void OnRowUpdating (RowUpdatingEventArgs value)
  151. {
  152. if (RowUpdating != null)
  153. RowUpdating (this, (OdbcRowUpdatingEventArgs) value);
  154. }
  155. [MonoTODO]
  156. object ICloneable.Clone ()
  157. {
  158. throw new NotImplementedException ();
  159. }
  160. #endregion // Methods
  161. #region Events and Delegates
  162. public event OdbcRowUpdatedEventHandler RowUpdated;
  163. public event OdbcRowUpdatingEventHandler RowUpdating;
  164. #endregion // Events and Delegates
  165. }
  166. }