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 using System.ComponentModel;
15 using System.Data.Common;
17 namespace System.Data.OleDb
19 public sealed class OleDbDataAdapter : DbDataAdapter, IDbDataAdapter
23 OleDbCommand deleteCommand;
24 OleDbCommand insertCommand;
25 OleDbCommand selectCommand;
26 OleDbCommand updateCommand;
27 MissingMappingAction missingMappingAction;
28 MissingSchemaAction missingSchemaAction;
30 static readonly object EventRowUpdated = new object ();
31 static readonly object EventRowUpdating = new object ();
37 public OleDbDataAdapter ()
38 : this (new OleDbCommand ())
42 public OleDbDataAdapter (OleDbCommand selectCommand)
44 DeleteCommand = new OleDbCommand ();
45 InsertCommand = new OleDbCommand ();
46 SelectCommand = selectCommand;
47 UpdateCommand = new OleDbCommand ();
50 public OleDbDataAdapter (string selectCommandText, OleDbConnection selectConnection)
51 : this (new OleDbCommand (selectCommandText, selectConnection))
55 public OleDbDataAdapter (string selectCommandText, string selectConnectionString)
56 : this (selectCommandText, new OleDbConnection (selectConnectionString))
64 public OleDbCommand DeleteCommand {
69 deleteCommand = value;
73 public OleDbCommand InsertCommand {
78 insertCommand = value;
82 public OleDbCommand SelectCommand {
87 selectCommand = value;
91 public OleDbCommand UpdateCommand {
96 updateCommand = value;
100 IDbCommand IDbDataAdapter.DeleteCommand {
102 return DeleteCommand;
105 if (!(value is OleDbCommand))
106 throw new ArgumentException ();
107 DeleteCommand = (OleDbCommand)value;
111 IDbCommand IDbDataAdapter.InsertCommand {
113 return InsertCommand;
116 if (!(value is OleDbCommand))
117 throw new ArgumentException ();
118 InsertCommand = (OleDbCommand)value;
122 IDbCommand IDbDataAdapter.SelectCommand {
124 return SelectCommand;
127 if (!(value is OleDbCommand))
128 throw new ArgumentException ();
129 SelectCommand = (OleDbCommand)value;
133 MissingMappingAction IDataAdapter.MissingMappingAction {
135 return missingMappingAction;
138 missingMappingAction = value;
142 MissingSchemaAction IDataAdapter.MissingSchemaAction {
144 return missingSchemaAction;
147 missingSchemaAction = value;
151 IDbCommand IDbDataAdapter.UpdateCommand {
153 return UpdateCommand;
156 if (!(value is OleDbCommand))
157 throw new ArgumentException ();
158 UpdateCommand = (OleDbCommand)value;
162 ITableMappingCollection IDataAdapter.TableMappings {
164 return TableMappings;
168 #endregion // Properties
172 public int Fill (DataTable dataTable, object ADODBRecordSet)
174 throw new NotImplementedException ();
177 public int Fill (DataSet dataSet, object ADODBRecordSet, string srcTable)
179 throw new NotImplementedException ();
182 public override int Fill (DataSet dataSet)
184 throw new NotImplementedException ();
187 protected override int Fill (DataTable dataTable, IDataReader dataReader)
189 throw new NotImplementedException ();
192 protected override int Fill (DataTable dataTable,
194 CommandBehavior behavior)
196 throw new NotImplementedException ();
199 protected override int Fill (DataSet dataSet,
201 IDataReader dataReader,
205 throw new NotImplementedException ();
208 protected override int Fill (DataSet dataSet,
213 CommandBehavior behavior)
215 throw new NotImplementedException ();
218 public override DataTable[] FillSchema (DataSet dataSet,
219 SchemaType schemaType)
221 throw new NotImplementedException ();
224 protected override DataTable FillSchema (DataTable dataTable,
225 SchemaType schemaType,
227 CommandBehavior behavior)
229 throw new NotImplementedException ();
232 protected override DataTable[] FillSchema (DataSet dataSet,
233 SchemaType schemaType,
236 CommandBehavior behavior)
238 throw new NotImplementedException ();
241 protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow,
243 StatementType statementType,
244 DataTableMapping tableMapping)
246 return new OleDbRowUpdatedEventArgs (dataRow, command,
247 statementType, tableMapping);
250 protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow,
252 StatementType statementType,
253 DataTableMapping tableMapping)
255 return new OleDbRowUpdatingEventArgs (dataRow, command,
256 statementType, tableMapping);
259 public override IDataParameter[] GetFillParameters ()
261 throw new NotImplementedException ();
264 protected override void OnRowUpdated (RowUpdatedEventArgs value)
266 OleDbRowUpdatedEventHandler handler = (OleDbRowUpdatedEventHandler) Events[EventRowUpdated];
267 if ((handler != null) && (value is OleDbRowUpdatedEventArgs))
268 handler (this, (OleDbRowUpdatedEventArgs) value);
271 protected override void OnRowUpdating (RowUpdatingEventArgs value)
273 OleDbRowUpdatingEventHandler handler = (OleDbRowUpdatingEventHandler) Events[EventRowUpdated];
274 if ((handler != null) && (value is OleDbRowUpdatingEventArgs))
275 handler (this, (OleDbRowUpdatingEventArgs) value);
278 public override int Update (DataSet dataSet)
280 throw new NotImplementedException ();
283 protected override int Update (DataRow[] dataRows,
284 DataTableMapping tableMapping)
286 throw new NotImplementedException ();
289 #endregion // Methods
291 #region Events and Delegates
293 public event OleDbRowUpdatedEventHandler RowUpdated {
294 add { Events.AddHandler (EventRowUpdated, value); }
295 remove { Events.RemoveHandler (EventRowUpdated, value); }
298 public event OleDbRowUpdatedEventHandler RowUpdating {
299 add { Events.AddHandler (EventRowUpdating, value); }
300 remove { Events.RemoveHandler (EventRowUpdating, value); }
303 #endregion // Events and Delegates