OleDbDataAdapter.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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. public sealed class OleDbDataAdapter : DbDataAdapter, IDbDataAdapter
  18. {
  19. #region Fields
  20. OleDbCommand deleteCommand;
  21. OleDbCommand insertCommand;
  22. OleDbCommand selectCommand;
  23. OleDbCommand updateCommand;
  24. MissingMappingAction missingMappingAction;
  25. MissingSchemaAction missingSchemaAction;
  26. static readonly object EventRowUpdated = new object ();
  27. static readonly object EventRowUpdating = new object ();
  28. #endregion
  29. #region Constructors
  30. public OleDbDataAdapter ()
  31. : this (new OleDbCommand ())
  32. {
  33. }
  34. public OleDbDataAdapter (OleDbCommand selectCommand)
  35. {
  36. DeleteCommand = new OleDbCommand ();
  37. InsertCommand = new OleDbCommand ();
  38. SelectCommand = selectCommand;
  39. UpdateCommand = new OleDbCommand ();
  40. }
  41. public OleDbDataAdapter (string selectCommandText, OleDbConnection selectConnection)
  42. : this (new OleDbCommand (selectCommandText, selectConnection))
  43. {
  44. }
  45. public OleDbDataAdapter (string selectCommandText, string selectConnectionString)
  46. : this (selectCommandText, new OleDbConnection (selectConnectionString))
  47. {
  48. }
  49. #endregion // Fields
  50. #region Properties
  51. public OleDbCommand DeleteCommand {
  52. get {
  53. return deleteCommand;
  54. }
  55. set {
  56. deleteCommand = value;
  57. }
  58. }
  59. public OleDbCommand InsertCommand {
  60. get {
  61. return insertCommand;
  62. }
  63. set {
  64. insertCommand = value;
  65. }
  66. }
  67. public OleDbCommand SelectCommand {
  68. get {
  69. return selectCommand;
  70. }
  71. set {
  72. selectCommand = value;
  73. }
  74. }
  75. public OleDbCommand UpdateCommand {
  76. get {
  77. return updateCommand;
  78. }
  79. set {
  80. updateCommand = value;
  81. }
  82. }
  83. IDbCommand IDbDataAdapter.DeleteCommand {
  84. get {
  85. return DeleteCommand;
  86. }
  87. set {
  88. if (!(value is OleDbCommand))
  89. throw new ArgumentException ();
  90. DeleteCommand = (OleDbCommand)value;
  91. }
  92. }
  93. IDbCommand IDbDataAdapter.InsertCommand {
  94. get {
  95. return InsertCommand;
  96. }
  97. set {
  98. if (!(value is OleDbCommand))
  99. throw new ArgumentException ();
  100. InsertCommand = (OleDbCommand)value;
  101. }
  102. }
  103. IDbCommand IDbDataAdapter.SelectCommand {
  104. get {
  105. return SelectCommand;
  106. }
  107. set {
  108. if (!(value is OleDbCommand))
  109. throw new ArgumentException ();
  110. SelectCommand = (OleDbCommand)value;
  111. }
  112. }
  113. MissingMappingAction IDataAdapter.MissingMappingAction {
  114. get {
  115. return missingMappingAction;
  116. }
  117. set {
  118. missingMappingAction = value;
  119. }
  120. }
  121. MissingSchemaAction IDataAdapter.MissingSchemaAction {
  122. get {
  123. return missingSchemaAction;
  124. }
  125. set {
  126. missingSchemaAction = value;
  127. }
  128. }
  129. IDbCommand IDbDataAdapter.UpdateCommand {
  130. get {
  131. return UpdateCommand;
  132. }
  133. set {
  134. if (!(value is OleDbCommand))
  135. throw new ArgumentException ();
  136. UpdateCommand = (OleDbCommand)value;
  137. }
  138. }
  139. ITableMappingCollection IDataAdapter.TableMappings {
  140. get {
  141. return TableMappings;
  142. }
  143. }
  144. #endregion // Properties
  145. #region Methods
  146. public int Fill (DataTable dataTable, object ADODBRecordSet)
  147. {
  148. throw new NotImplementedException ();
  149. }
  150. public int Fill (DataSet dataSet, object ADODBRecordSet, string srcTable)
  151. {
  152. throw new NotImplementedException ();
  153. }
  154. public override int Fill (DataSet dataSet)
  155. {
  156. throw new NotImplementedException ();
  157. }
  158. protected override int Fill (DataTable dataTable, IDataReader dataReader)
  159. {
  160. throw new NotImplementedException ();
  161. }
  162. protected override int Fill (DataTable dataTable,
  163. IDbCommand command,
  164. CommandBehavior behavior)
  165. {
  166. throw new NotImplementedException ();
  167. }
  168. protected override int Fill (DataSet dataSet,
  169. string srcTable,
  170. IDataReader dataReader,
  171. int startRecord,
  172. int maxRecords)
  173. {
  174. throw new NotImplementedException ();
  175. }
  176. protected override int Fill (DataSet dataSet,
  177. int startRecord,
  178. int maxRecords,
  179. string srcTable,
  180. IDbCommand command,
  181. CommandBehavior behavior)
  182. {
  183. throw new NotImplementedException ();
  184. }
  185. public override DataTable[] FillSchema (DataSet dataSet,
  186. SchemaType schemaType)
  187. {
  188. throw new NotImplementedException ();
  189. }
  190. protected override DataTable FillSchema (DataTable dataTable,
  191. SchemaType schemaType,
  192. IDbCommand command,
  193. CommandBehavior behavior)
  194. {
  195. throw new NotImplementedException ();
  196. }
  197. protected override DataTable[] FillSchema (DataSet dataSet,
  198. SchemaType schemaType,
  199. IDbCommand command,
  200. string srcTable,
  201. CommandBehavior behavior)
  202. {
  203. throw new NotImplementedException ();
  204. }
  205. protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow,
  206. IDbCommand command,
  207. StatementType statementType,
  208. DataTableMapping tableMapping)
  209. {
  210. return new OleDbRowUpdatedEventArgs (dataRow, command,
  211. statementType, tableMapping);
  212. }
  213. protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow,
  214. IDbCommand command,
  215. StatementType statementType,
  216. DataTableMapping tableMapping)
  217. {
  218. return new OleDbRowUpdatingEventArgs (dataRow, command,
  219. statementType, tableMapping);
  220. }
  221. public override IDataParameter[] GetFillParameters ()
  222. {
  223. throw new NotImplementedException ();
  224. }
  225. protected override void OnRowUpdated (RowUpdatedEventArgs value)
  226. {
  227. OleDbRowUpdatedEventHandler handler = (OleDbRowUpdatedEventHandler) Events[EventRowUpdated];
  228. if ((handler != null) && (value is OleDbRowUpdatedEventArgs))
  229. handler (this, (OleDbRowUpdatedEventArgs) value);
  230. }
  231. protected override void OnRowUpdating (RowUpdatingEventArgs value)
  232. {
  233. OleDbRowUpdatingEventHandler handler = (OleDbRowUpdatingEventHandler) Events[EventRowUpdated];
  234. if ((handler != null) && (value is OleDbRowUpdatingEventArgs))
  235. handler (this, (OleDbRowUpdatingEventArgs) value);
  236. }
  237. public override int Update (DataSet dataSet)
  238. {
  239. throw new NotImplementedException ();
  240. }
  241. protected override int Update (DataRow[] dataRows,
  242. DataTableMapping tableMapping)
  243. {
  244. throw new NotImplementedException ();
  245. }
  246. #endregion // Methods
  247. #region Events and Delegates
  248. public event OleDbRowUpdatedEventHandler RowUpdated {
  249. add { Events.AddHandler (EventRowUpdated, value); }
  250. remove { Events.RemoveHandler (EventRowUpdated, value); }
  251. }
  252. public event OleDbRowUpdatedEventHandler RowUpdating {
  253. add { Events.AddHandler (EventRowUpdating, value); }
  254. remove { Events.RemoveHandler (EventRowUpdating, value); }
  255. }
  256. #endregion // Events and Delegates
  257. }
  258. }