OleDbDataAdapter.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. MissingMappingAction missingMappingAction;
  50. MissingSchemaAction missingSchemaAction;
  51. #endregion
  52. #region Constructors
  53. public OleDbDataAdapter () : this ((OleDbCommand) null)
  54. {
  55. }
  56. public OleDbDataAdapter (OleDbCommand selectCommand)
  57. {
  58. SelectCommand = selectCommand;
  59. }
  60. public OleDbDataAdapter (string selectCommandText, OleDbConnection selectConnection)
  61. : this (new OleDbCommand (selectCommandText, selectConnection))
  62. {
  63. }
  64. public OleDbDataAdapter (string selectCommandText, string selectConnectionString)
  65. : this (selectCommandText, new OleDbConnection (selectConnectionString))
  66. {
  67. }
  68. #endregion // Fields
  69. #region Properties
  70. [DefaultValue (null)]
  71. [DataCategory ("Update")]
  72. #if !NET_2_0
  73. [DataSysDescriptionAttribute ("Used during Update for deleted rows in DataSet.")]
  74. #endif
  75. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing)]
  76. public new OleDbCommand DeleteCommand {
  77. get {
  78. return deleteCommand;
  79. }
  80. set {
  81. deleteCommand = value;
  82. }
  83. }
  84. [DefaultValue (null)]
  85. [DataCategory ("Update")]
  86. #if !NET_2_0
  87. [DataSysDescriptionAttribute ("Used during Update for new rows in DataSet.")]
  88. #endif
  89. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing)]
  90. public new OleDbCommand InsertCommand {
  91. get {
  92. return insertCommand;
  93. }
  94. set {
  95. insertCommand = value;
  96. }
  97. }
  98. [DefaultValue (null)]
  99. [DataCategory ("Fill")]
  100. #if !NET_2_0
  101. [DataSysDescriptionAttribute ("Used during Fill/FillSchema.")]
  102. #endif
  103. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing)]
  104. public new OleDbCommand SelectCommand {
  105. get {
  106. return selectCommand;
  107. }
  108. set {
  109. selectCommand = value;
  110. }
  111. }
  112. [DefaultValue (null)]
  113. [DataCategory ("Update")]
  114. #if !NET_2_0
  115. [DataSysDescriptionAttribute ("Used during Update for modified rows in DataSet.")]
  116. #endif
  117. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing)]
  118. public new OleDbCommand UpdateCommand {
  119. get { return updateCommand; }
  120. set { updateCommand = value; }
  121. }
  122. IDbCommand IDbDataAdapter.DeleteCommand {
  123. get { return DeleteCommand; }
  124. set { DeleteCommand = (OleDbCommand) value; }
  125. }
  126. IDbCommand IDbDataAdapter.InsertCommand {
  127. get { return InsertCommand; }
  128. set { InsertCommand = (OleDbCommand) value; }
  129. }
  130. IDbCommand IDbDataAdapter.SelectCommand {
  131. get {
  132. return SelectCommand;
  133. }
  134. set {
  135. SelectCommand = (OleDbCommand) value;
  136. }
  137. }
  138. MissingMappingAction IDataAdapter.MissingMappingAction {
  139. get { return missingMappingAction; }
  140. set { missingMappingAction = value; }
  141. }
  142. MissingSchemaAction IDataAdapter.MissingSchemaAction {
  143. get { return missingSchemaAction; }
  144. set { missingSchemaAction = value; }
  145. }
  146. IDbCommand IDbDataAdapter.UpdateCommand {
  147. get { return UpdateCommand; }
  148. set { UpdateCommand = (OleDbCommand) value; }
  149. }
  150. ITableMappingCollection IDataAdapter.TableMappings {
  151. get { return TableMappings; }
  152. }
  153. #endregion // Properties
  154. #region Methods
  155. protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow,
  156. IDbCommand command,
  157. StatementType statementType,
  158. DataTableMapping tableMapping)
  159. {
  160. return new OleDbRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
  161. }
  162. protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow,
  163. IDbCommand command,
  164. StatementType statementType,
  165. DataTableMapping tableMapping)
  166. {
  167. return new OleDbRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
  168. }
  169. protected override void OnRowUpdated (RowUpdatedEventArgs value)
  170. {
  171. if (RowUpdated != null)
  172. RowUpdated (this, (OleDbRowUpdatedEventArgs) value);
  173. }
  174. protected override void OnRowUpdating (RowUpdatingEventArgs value)
  175. {
  176. if (RowUpdating != null)
  177. RowUpdating (this, (OleDbRowUpdatingEventArgs) value);
  178. }
  179. [MonoTODO]
  180. public int Fill(DataTable datatable, Object adoDBRecordSet)
  181. {
  182. throw new NotImplementedException ();
  183. }
  184. [MonoTODO]
  185. public int Fill(DataSet dataset, Object adoDBRecordSet, String srcTable)
  186. {
  187. throw new NotImplementedException ();
  188. }
  189. [MonoTODO]
  190. object ICloneable.Clone ()
  191. {
  192. throw new NotImplementedException ();
  193. }
  194. #if !NET_2_0
  195. [MonoTODO]
  196. protected override void Dispose (bool disposing)
  197. {
  198. base.Dispose (disposing);
  199. }
  200. #endif
  201. #endregion // Methods
  202. #region Events and Delegates
  203. #if !NET_2_0
  204. [DataSysDescription ("Event triggered before every DataRow during Update.")]
  205. #endif
  206. [DataCategory ("DataCategory_Update")]
  207. public event OleDbRowUpdatedEventHandler RowUpdated;
  208. #if !NET_2_0
  209. [DataSysDescription ("Event triggered after every DataRow during Update.")]
  210. #endif
  211. [DataCategory ("DataCategory_Update")]
  212. public event OleDbRowUpdatingEventHandler RowUpdating;
  213. #endregion // Events and Delegates
  214. }
  215. }