* OleDbDataReader.cs: Removed bogus MonoTODO.
[mono.git] / mcs / class / System.Data / System.Data.OleDb / OleDbDataAdapter.cs
1 //
2 // System.Data.OleDb.OleDbDataAdapter
3 //
4 // Authors:
5 //   Rodrigo Moya (rodrigo@ximian.com)
6 //   Tim Coleman (tim@timcoleman.com)
7 //
8 // Copyright (C) Rodrigo Moya, 2002
9 // Copyright (C) Tim Coleman, 2002
10 //
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
35 using System;
36 using System.ComponentModel;
37 using System.Data;
38 using System.Data.Common;
39
40 namespace System.Data.OleDb
41 {
42         [DefaultEvent ("RowUpdated")]
43         [DesignerAttribute ("Microsoft.VSDesigner.Data.VS.OleDbDataAdapterDesigner, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.ComponentModel.Design.IDesigner")]
44         [ToolboxItemAttribute ("Microsoft.VSDesigner.Data.VS.OleDbDataAdapterToolboxItem, "+ Consts.AssemblyMicrosoft_VSDesigner)]
45         public sealed class OleDbDataAdapter : DbDataAdapter, IDbDataAdapter, ICloneable
46         {
47                 #region Fields
48
49                 OleDbCommand deleteCommand;
50                 OleDbCommand insertCommand;
51                 OleDbCommand selectCommand;
52                 OleDbCommand updateCommand;
53                 MissingMappingAction missingMappingAction;
54                 MissingSchemaAction missingSchemaAction;
55
56                 #endregion
57
58                 #region Constructors
59
60                 public OleDbDataAdapter ()
61                         : this (new OleDbCommand ())
62                 {
63                 }
64
65                 public OleDbDataAdapter (OleDbCommand selectCommand)
66                 {
67                         DeleteCommand = new OleDbCommand ();
68                         InsertCommand = new OleDbCommand ();
69                         SelectCommand = selectCommand;
70                         UpdateCommand = new OleDbCommand ();
71                 }
72
73                 public OleDbDataAdapter (string selectCommandText, OleDbConnection selectConnection)
74                         : this (new OleDbCommand (selectCommandText, selectConnection))
75                 {
76                 }
77
78                 public OleDbDataAdapter (string selectCommandText, string selectConnectionString)
79                         : this (selectCommandText, new OleDbConnection (selectConnectionString))
80                 {
81                 }
82
83                 #endregion // Fields
84
85                 #region Properties
86                 
87                 [DefaultValue (null)]
88                 [DataCategory ("Update")]
89 #if !NET_2_0
90                 [DataSysDescriptionAttribute ("Used during Update for deleted rows in DataSet.")]
91 #endif
92                 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing)]
93                 public new OleDbCommand DeleteCommand {
94                         get {
95                                 return deleteCommand;
96                         }
97                         set {
98                                 deleteCommand = value;
99                         }
100                 }
101
102                 [DefaultValue (null)]
103                 [DataCategory ("Update")]
104 #if !NET_2_0
105                 [DataSysDescriptionAttribute ("Used during Update for new rows in DataSet.")]
106 #endif
107                 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing)]
108                 public new OleDbCommand InsertCommand {
109                         get {
110                                 return insertCommand;
111                         }
112                         set {
113                                 insertCommand = value;
114                         }
115                 }
116
117                 [DefaultValue (null)]
118                 [DataCategory ("Fill")]
119 #if !NET_2_0
120                 [DataSysDescriptionAttribute ("Used during Fill/FillSchema.")]
121 #endif
122                 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing)]
123                 public new OleDbCommand SelectCommand {
124                         get {
125                                 return selectCommand;
126                         }
127                         set {
128                                 selectCommand = value;
129                         }
130                 }
131
132                 [DefaultValue (null)]
133                 [DataCategory ("Update")]
134 #if !NET_2_0
135                 [DataSysDescriptionAttribute ("Used during Update for modified rows in DataSet.")]
136 #endif
137                 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing)]
138                 public new OleDbCommand UpdateCommand {
139                         get {
140                                 return updateCommand;
141                         }
142                         set {
143                                 updateCommand = value;
144                         }
145                 }
146
147                 IDbCommand IDbDataAdapter.DeleteCommand {
148                         get {
149                                 return DeleteCommand;
150                         }
151                         set { 
152                                 if (!(value is OleDbCommand))
153                                         throw new ArgumentException ();
154                                 DeleteCommand = (OleDbCommand)value;
155                         }
156                 }
157
158                 IDbCommand IDbDataAdapter.InsertCommand {
159                         get {
160                                 return InsertCommand;
161                         }
162                         set {
163                                 if (!(value is OleDbCommand))
164                                         throw new ArgumentException ();
165                                 InsertCommand = (OleDbCommand)value;
166                         }
167                 }
168
169                 IDbCommand IDbDataAdapter.SelectCommand {
170                         get {
171                                 return SelectCommand;
172                         }
173                         set {
174                                 if (!(value is OleDbCommand))
175                                         throw new ArgumentException ();
176                                 SelectCommand = (OleDbCommand)value;
177                         }
178                 }
179
180                 MissingMappingAction IDataAdapter.MissingMappingAction {
181                         get {
182                                 return missingMappingAction;
183                         }
184                         set {
185                                 missingMappingAction = value;
186                         }
187                 }
188
189                 MissingSchemaAction IDataAdapter.MissingSchemaAction {
190                         get {
191                                 return missingSchemaAction;
192                         }
193                         set {
194                                 missingSchemaAction = value;
195                         }
196                 }
197                 
198                 IDbCommand IDbDataAdapter.UpdateCommand {
199                         get {
200                                 return UpdateCommand;
201                         }
202                         set {
203                                 if (!(value is OleDbCommand))
204                                         throw new ArgumentException ();
205                                 UpdateCommand = (OleDbCommand)value;
206                         }
207                 }
208
209                 ITableMappingCollection IDataAdapter.TableMappings {
210                         get {
211                                 return TableMappings;
212                         }
213                 }
214
215                 #endregion // Properties
216
217                 #region Methods
218
219                 protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow,
220                                                                               IDbCommand command,
221                                                                               StatementType statementType,
222                                                                               DataTableMapping tableMapping) 
223                 {
224                         return new OleDbRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
225                 }
226
227
228                 protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow,
229                                                                                 IDbCommand command,
230                                                                                 StatementType statementType,
231                                                                                 DataTableMapping tableMapping)
232                 {
233                         return new OleDbRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
234                 }
235
236                 protected override void OnRowUpdated (RowUpdatedEventArgs value)
237                 {
238                         if (RowUpdated != null)
239                                 RowUpdated (this, (OleDbRowUpdatedEventArgs) value);
240                 }
241
242                 protected override void OnRowUpdating (RowUpdatingEventArgs value)
243                 {
244                         if (RowUpdating != null)
245                                 RowUpdating (this, (OleDbRowUpdatingEventArgs) value);
246                 }
247                 
248                 [MonoTODO]
249                 public int Fill(DataTable datatable, Object adoDBRecordSet)
250                 {
251                         throw new NotImplementedException ();
252                 }
253
254                 [MonoTODO]
255                 public int Fill(DataSet dataset, Object adoDBRecordSet, String srcTable)
256                 {
257                         throw new NotImplementedException ();
258                 }
259
260                 [MonoTODO]
261                 object ICloneable.Clone ()
262                 {
263                         throw new NotImplementedException ();
264                 }
265
266 #if !NET_2_0
267                 [MonoTODO]
268                 protected override void Dispose (bool disposing)
269                 {
270                         base.Dispose (disposing);
271                 }
272 #endif
273
274                 #endregion // Methods
275
276                 #region Events and Delegates
277
278 #if !NET_2_0
279                 [DataSysDescription ("Event triggered before every DataRow during Update.")]
280 #endif
281                 [DataCategory ("DataCategory_Update")]
282                 public event OleDbRowUpdatedEventHandler RowUpdated;
283
284 #if !NET_2_0
285                 [DataSysDescription ("Event triggered after every DataRow during Update.")]
286 #endif
287                 [DataCategory ("DataCategory_Update")]
288                 public event OleDbRowUpdatingEventHandler RowUpdating;
289
290                 #endregion // Events and Delegates
291         }
292 }