2 // System.Data.OleDb.OleDbDataAdapter
\r
5 // Rodrigo Moya (rodrigo@ximian.com)
\r
6 // Tim Coleman (tim@timcoleman.com)
\r
7 // Konstantin Triger <kostat@mainsoft.com>
\r
8 // Boris Kirzner <borisk@mainsoft.com>
\r
10 // Copyright (C) Rodrigo Moya, 2002
\r
11 // Copyright (C) Tim Coleman, 2002
\r
12 // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
\r
16 // Permission is hereby granted, free of charge, to any person obtaining
\r
17 // a copy of this software and associated documentation files (the
\r
18 // "Software"), to deal in the Software without restriction, including
\r
19 // without limitation the rights to use, copy, modify, merge, publish,
\r
20 // distribute, sublicense, and/or sell copies of the Software, and to
\r
21 // permit persons to whom the Software is furnished to do so, subject to
\r
22 // the following conditions:
\r
24 // The above copyright notice and this permission notice shall be
\r
25 // included in all copies or substantial portions of the Software.
\r
27 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
28 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
29 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
30 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
\r
31 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
\r
32 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
\r
33 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
38 using System.ComponentModel;
\r
40 using System.Data.Common;
\r
42 namespace System.Data.OleDb
\r
44 public sealed class OleDbDataAdapter : DbDataAdapter, IDbDataAdapter
\r
48 OleDbCommand deleteCommand;
\r
49 OleDbCommand insertCommand;
\r
50 OleDbCommand selectCommand;
\r
51 OleDbCommand updateCommand;
\r
55 #region Constructors
\r
57 public OleDbDataAdapter ()
\r
58 : this (new OleDbCommand ())
\r
62 public OleDbDataAdapter (OleDbCommand selectCommand)
\r
64 DeleteCommand = new OleDbCommand ();
\r
65 InsertCommand = new OleDbCommand ();
\r
66 SelectCommand = selectCommand;
\r
67 UpdateCommand = new OleDbCommand ();
\r
70 public OleDbDataAdapter (string selectCommandText, OleDbConnection selectConnection)
\r
71 : this (new OleDbCommand (selectCommandText, selectConnection))
\r
75 public OleDbDataAdapter (string selectCommandText, string selectConnectionString)
\r
76 : this (selectCommandText, new OleDbConnection (selectConnectionString))
\r
80 #endregion // Fields
\r
84 public OleDbCommand DeleteCommand {
\r
86 return deleteCommand;
\r
89 deleteCommand = value;
\r
93 public OleDbCommand InsertCommand {
\r
95 return insertCommand;
\r
98 insertCommand = value;
\r
102 public OleDbCommand SelectCommand {
\r
104 return selectCommand;
\r
107 selectCommand = value;
\r
111 public OleDbCommand UpdateCommand {
\r
113 return updateCommand;
\r
116 updateCommand = value;
\r
120 IDbCommand IDbDataAdapter.DeleteCommand {
\r
122 return DeleteCommand;
\r
125 if (value != null && !(value is OleDbCommand))
\r
126 throw new ArgumentException ("DeleteCommand is not of Type OleDbCommand");
\r
127 DeleteCommand = (OleDbCommand)value;
\r
131 IDbCommand IDbDataAdapter.InsertCommand {
\r
133 return InsertCommand;
\r
136 if (value != null && !(value is OleDbCommand))
\r
137 throw new ArgumentException ("InsertCommand is not of Type OleDbCommand");
\r
138 InsertCommand = (OleDbCommand)value;
\r
142 IDbCommand IDbDataAdapter.SelectCommand {
\r
144 return SelectCommand;
\r
147 if (value != null && !(value is OleDbCommand))
\r
148 throw new ArgumentException ("SelectCommand is not of Type OleDbCommand");
\r
149 SelectCommand = (OleDbCommand)value;
\r
154 IDbCommand IDbDataAdapter.UpdateCommand {
\r
156 return UpdateCommand;
\r
159 if (value != null && !(value is OleDbCommand))
\r
160 throw new ArgumentException ("UpdateCommand is not of Type OleDbCommand");
\r
161 UpdateCommand = (OleDbCommand)value;
\r
165 ITableMappingCollection IDataAdapter.TableMappings {
\r
167 return TableMappings;
\r
171 #endregion // Properties
\r
175 protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow,
\r
176 IDbCommand command,
\r
177 StatementType statementType,
\r
178 DataTableMapping tableMapping)
\r
180 return new OleDbRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
\r
184 protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow,
\r
185 IDbCommand command,
\r
186 StatementType statementType,
\r
187 DataTableMapping tableMapping)
\r
189 return new OleDbRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
\r
192 protected override void OnRowUpdated (RowUpdatedEventArgs value)
\r
194 if (RowUpdated != null)
\r
195 RowUpdated (this, (OleDbRowUpdatedEventArgs) value);
\r
198 protected override void OnRowUpdating (RowUpdatingEventArgs value)
\r
200 if (RowUpdating != null)
\r
201 RowUpdating (this, (OleDbRowUpdatingEventArgs) value);
\r
204 #endregion // Methods
\r
206 #region Events and Delegates
\r
208 public event OleDbRowUpdatedEventHandler RowUpdated;
\r
209 public event OleDbRowUpdatingEventHandler RowUpdating;
\r
211 #endregion // Events and Delegates
\r