OleDbDataAdapter.cs 6.7 KB

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