2 // System.Data.OleDb.OleDbDataAdapter
5 // Rodrigo Moya (rodrigo@ximian.com)
6 // Tim Coleman (tim@timcoleman.com)
8 // Copyright (C) Rodrigo Moya, 2002
9 // Copyright (C) Tim Coleman, 2002
13 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
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:
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
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.
36 using System.ComponentModel;
38 using System.Data.Common;
40 namespace System.Data.OleDb
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
49 OleDbCommand deleteCommand;
50 OleDbCommand insertCommand;
51 OleDbCommand selectCommand;
52 OleDbCommand updateCommand;
53 MissingMappingAction missingMappingAction;
54 MissingSchemaAction missingSchemaAction;
60 public OleDbDataAdapter ()
61 : this (new OleDbCommand ())
65 public OleDbDataAdapter (OleDbCommand selectCommand)
67 DeleteCommand = new OleDbCommand ();
68 InsertCommand = new OleDbCommand ();
69 SelectCommand = selectCommand;
70 UpdateCommand = new OleDbCommand ();
73 public OleDbDataAdapter (string selectCommandText, OleDbConnection selectConnection)
74 : this (new OleDbCommand (selectCommandText, selectConnection))
78 public OleDbDataAdapter (string selectCommandText, string selectConnectionString)
79 : this (selectCommandText, new OleDbConnection (selectConnectionString))
88 [DataCategory ("Update")]
90 [DataSysDescriptionAttribute ("Used during Update for deleted rows in DataSet.")]
92 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing)]
93 public new OleDbCommand DeleteCommand {
98 deleteCommand = value;
102 [DefaultValue (null)]
103 [DataCategory ("Update")]
105 [DataSysDescriptionAttribute ("Used during Update for new rows in DataSet.")]
107 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing)]
108 public new OleDbCommand InsertCommand {
110 return insertCommand;
113 insertCommand = value;
117 [DefaultValue (null)]
118 [DataCategory ("Fill")]
120 [DataSysDescriptionAttribute ("Used during Fill/FillSchema.")]
122 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing)]
123 public new OleDbCommand SelectCommand {
125 return selectCommand;
128 selectCommand = value;
132 [DefaultValue (null)]
133 [DataCategory ("Update")]
135 [DataSysDescriptionAttribute ("Used during Update for modified rows in DataSet.")]
137 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing)]
138 public new OleDbCommand UpdateCommand {
140 return updateCommand;
143 updateCommand = value;
147 IDbCommand IDbDataAdapter.DeleteCommand {
149 return DeleteCommand;
152 if (!(value is OleDbCommand))
153 throw new ArgumentException ();
154 DeleteCommand = (OleDbCommand)value;
158 IDbCommand IDbDataAdapter.InsertCommand {
160 return InsertCommand;
163 if (!(value is OleDbCommand))
164 throw new ArgumentException ();
165 InsertCommand = (OleDbCommand)value;
169 IDbCommand IDbDataAdapter.SelectCommand {
171 return SelectCommand;
174 if (!(value is OleDbCommand))
175 throw new ArgumentException ();
176 SelectCommand = (OleDbCommand)value;
180 MissingMappingAction IDataAdapter.MissingMappingAction {
182 return missingMappingAction;
185 missingMappingAction = value;
189 MissingSchemaAction IDataAdapter.MissingSchemaAction {
191 return missingSchemaAction;
194 missingSchemaAction = value;
198 IDbCommand IDbDataAdapter.UpdateCommand {
200 return UpdateCommand;
203 if (!(value is OleDbCommand))
204 throw new ArgumentException ();
205 UpdateCommand = (OleDbCommand)value;
209 ITableMappingCollection IDataAdapter.TableMappings {
211 return TableMappings;
215 #endregion // Properties
219 protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow,
221 StatementType statementType,
222 DataTableMapping tableMapping)
224 return new OleDbRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
228 protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow,
230 StatementType statementType,
231 DataTableMapping tableMapping)
233 return new OleDbRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
236 protected override void OnRowUpdated (RowUpdatedEventArgs value)
238 if (RowUpdated != null)
239 RowUpdated (this, (OleDbRowUpdatedEventArgs) value);
242 protected override void OnRowUpdating (RowUpdatingEventArgs value)
244 if (RowUpdating != null)
245 RowUpdating (this, (OleDbRowUpdatingEventArgs) value);
249 public int Fill(DataTable datatable, Object adoDBRecordSet)
251 throw new NotImplementedException ();
255 public int Fill(DataSet dataset, Object adoDBRecordSet, String srcTable)
257 throw new NotImplementedException ();
261 object ICloneable.Clone ()
263 throw new NotImplementedException ();
268 protected override void Dispose (bool disposing)
270 base.Dispose (disposing);
274 #endregion // Methods
276 #region Events and Delegates
279 [DataSysDescription ("Event triggered before every DataRow during Update.")]
281 [DataCategory ("DataCategory_Update")]
282 public event OleDbRowUpdatedEventHandler RowUpdated;
285 [DataSysDescription ("Event triggered after every DataRow during Update.")]
287 [DataCategory ("DataCategory_Update")]
288 public event OleDbRowUpdatingEventHandler RowUpdating;
290 #endregion // Events and Delegates