OleDbDataAdapter.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. using System;
  12. using System.ComponentModel;
  13. using System.Data;
  14. using System.Data.Common;
  15. namespace System.Data.OleDb
  16. {
  17. [DefaultEvent ("RowUpdated")]
  18. [DesignerAttribute ("Microsoft.VSDesigner.Data.VS.OleDbDataAdapterDesigner, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.ComponentModel.Design.IDesigner")]
  19. [ToolboxItemAttribute ("Microsoft.VSDesigner.Data.VS.OleDbDataAdapterToolboxItem, "+ Consts.AssemblyMicrosoft_VSDesigner)]
  20. public sealed class OleDbDataAdapter : DbDataAdapter, IDbDataAdapter
  21. {
  22. #region Fields
  23. OleDbCommand deleteCommand;
  24. OleDbCommand insertCommand;
  25. OleDbCommand selectCommand;
  26. OleDbCommand updateCommand;
  27. MissingMappingAction missingMappingAction;
  28. MissingSchemaAction missingSchemaAction;
  29. #endregion
  30. #region Constructors
  31. public OleDbDataAdapter ()
  32. : this (new OleDbCommand ())
  33. {
  34. }
  35. public OleDbDataAdapter (OleDbCommand selectCommand)
  36. {
  37. DeleteCommand = new OleDbCommand ();
  38. InsertCommand = new OleDbCommand ();
  39. SelectCommand = selectCommand;
  40. UpdateCommand = new OleDbCommand ();
  41. }
  42. public OleDbDataAdapter (string selectCommandText, OleDbConnection selectConnection)
  43. : this (new OleDbCommand (selectCommandText, selectConnection))
  44. {
  45. }
  46. public OleDbDataAdapter (string selectCommandText, string selectConnectionString)
  47. : this (selectCommandText, new OleDbConnection (selectConnectionString))
  48. {
  49. }
  50. #endregion // Fields
  51. #region Properties
  52. [DefaultValue ("")]
  53. [DataCategory ("Update")]
  54. [DataSysDescriptionAttribute ("Used during Update for deleted rows in DataSet")]
  55. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
  56. public OleDbCommand DeleteCommand {
  57. get {
  58. return deleteCommand;
  59. }
  60. set {
  61. deleteCommand = value;
  62. }
  63. }
  64. [DefaultValue ("")]
  65. [DataCategory ("Update")]
  66. [DataSysDescriptionAttribute ("Used during Update for new rows in DataSet")]
  67. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
  68. public OleDbCommand InsertCommand {
  69. get {
  70. return insertCommand;
  71. }
  72. set {
  73. insertCommand = value;
  74. }
  75. }
  76. [DefaultValue ("")]
  77. [DataCategory ("Fill")]
  78. [DataSysDescriptionAttribute ("Used during Fill/FillSchema")]
  79. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
  80. public OleDbCommand SelectCommand {
  81. get {
  82. return selectCommand;
  83. }
  84. set {
  85. selectCommand = value;
  86. }
  87. }
  88. [DefaultValue ("")]
  89. [DataCategory ("Update")]
  90. [DataSysDescriptionAttribute ("Used during Update for modified rows in DataSet")]
  91. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
  92. public OleDbCommand UpdateCommand {
  93. get {
  94. return updateCommand;
  95. }
  96. set {
  97. updateCommand = value;
  98. }
  99. }
  100. IDbCommand IDbDataAdapter.DeleteCommand {
  101. get {
  102. return DeleteCommand;
  103. }
  104. set {
  105. if (!(value is OleDbCommand))
  106. throw new ArgumentException ();
  107. DeleteCommand = (OleDbCommand)value;
  108. }
  109. }
  110. IDbCommand IDbDataAdapter.InsertCommand {
  111. get {
  112. return InsertCommand;
  113. }
  114. set {
  115. if (!(value is OleDbCommand))
  116. throw new ArgumentException ();
  117. InsertCommand = (OleDbCommand)value;
  118. }
  119. }
  120. IDbCommand IDbDataAdapter.SelectCommand {
  121. get {
  122. return SelectCommand;
  123. }
  124. set {
  125. if (!(value is OleDbCommand))
  126. throw new ArgumentException ();
  127. SelectCommand = (OleDbCommand)value;
  128. }
  129. }
  130. MissingMappingAction IDataAdapter.MissingMappingAction {
  131. get {
  132. return missingMappingAction;
  133. }
  134. set {
  135. missingMappingAction = value;
  136. }
  137. }
  138. MissingSchemaAction IDataAdapter.MissingSchemaAction {
  139. get {
  140. return missingSchemaAction;
  141. }
  142. set {
  143. missingSchemaAction = value;
  144. }
  145. }
  146. IDbCommand IDbDataAdapter.UpdateCommand {
  147. get {
  148. return UpdateCommand;
  149. }
  150. set {
  151. if (!(value is OleDbCommand))
  152. throw new ArgumentException ();
  153. UpdateCommand = (OleDbCommand)value;
  154. }
  155. }
  156. ITableMappingCollection IDataAdapter.TableMappings {
  157. get {
  158. return TableMappings;
  159. }
  160. }
  161. #endregion // Properties
  162. #region Methods
  163. protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow,
  164. IDbCommand command,
  165. StatementType statementType,
  166. DataTableMapping tableMapping)
  167. {
  168. return new OleDbRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
  169. }
  170. protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow,
  171. IDbCommand command,
  172. StatementType statementType,
  173. DataTableMapping tableMapping)
  174. {
  175. return new OleDbRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
  176. }
  177. protected override void OnRowUpdated (RowUpdatedEventArgs value)
  178. {
  179. if (RowUpdated != null)
  180. RowUpdated (this, (OleDbRowUpdatedEventArgs) value);
  181. }
  182. protected override void OnRowUpdating (RowUpdatingEventArgs value)
  183. {
  184. if (RowUpdating != null)
  185. RowUpdating (this, (OleDbRowUpdatingEventArgs) value);
  186. }
  187. [MonoTODO]
  188. public int Fill(DataTable datatable, Object adoDBRecordSet) {
  189. throw new NotImplementedException ();
  190. }
  191. [MonoTODO]
  192. public int Fill(DataSet dataset, Object adoDBRecordSet, String srcTable) {
  193. throw new NotImplementedException ();
  194. }
  195. #endregion // Methods
  196. #region Events and Delegates
  197. [DataSysDescription ("DbDataAdapter_RowUpdated")]
  198. [DataCategory ("DataCategory_Update")]
  199. public event OleDbRowUpdatedEventHandler RowUpdated;
  200. [DataSysDescription ("DbDataAdapter_RowUpdating")]
  201. [DataCategory ("DataCategory_Update")]
  202. public event OleDbRowUpdatingEventHandler RowUpdating;
  203. #endregion // Events and Delegates
  204. [MonoTODO]
  205. protected override void Dispose (bool disposing)
  206. {
  207. base.Dispose (disposing);
  208. }
  209. }
  210. }