**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Data / System.Data.OleDb / OleDbDataAdapter.cs
blob919b11a72248ba939385d088a2e58980d09f12d0
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
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:
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.
35 using System;
36 using System.ComponentModel;
37 using System.Data;
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
47 #region Fields
49 OleDbCommand deleteCommand;
50 OleDbCommand insertCommand;
51 OleDbCommand selectCommand;
52 OleDbCommand updateCommand;
53 MissingMappingAction missingMappingAction;
54 MissingSchemaAction missingSchemaAction;
56 #endregion
58 #region Constructors
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))
83 #endregion // Fields
85 #region Properties
87 [DefaultValue ("")]
88 [DataCategory ("Update")]
89 [DataSysDescriptionAttribute ("Used during Update for deleted rows in DataSet")]
90 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
91 public OleDbCommand DeleteCommand {
92 get {
93 return deleteCommand;
95 set {
96 deleteCommand = value;
100 [DefaultValue ("")]
101 [DataCategory ("Update")]
102 [DataSysDescriptionAttribute ("Used during Update for new rows in DataSet")]
103 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
104 public OleDbCommand InsertCommand {
105 get {
106 return insertCommand;
108 set {
109 insertCommand = value;
113 [DefaultValue ("")]
114 [DataCategory ("Fill")]
115 [DataSysDescriptionAttribute ("Used during Fill/FillSchema")]
116 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
117 public OleDbCommand SelectCommand {
118 get {
119 return selectCommand;
121 set {
122 selectCommand = value;
126 [DefaultValue ("")]
127 [DataCategory ("Update")]
128 [DataSysDescriptionAttribute ("Used during Update for modified rows in DataSet")]
129 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
130 public OleDbCommand UpdateCommand {
131 get {
132 return updateCommand;
134 set {
135 updateCommand = value;
139 IDbCommand IDbDataAdapter.DeleteCommand {
140 get {
141 return DeleteCommand;
143 set {
144 if (!(value is OleDbCommand))
145 throw new ArgumentException ();
146 DeleteCommand = (OleDbCommand)value;
150 IDbCommand IDbDataAdapter.InsertCommand {
151 get {
152 return InsertCommand;
154 set {
155 if (!(value is OleDbCommand))
156 throw new ArgumentException ();
157 InsertCommand = (OleDbCommand)value;
161 IDbCommand IDbDataAdapter.SelectCommand {
162 get {
163 return SelectCommand;
165 set {
166 if (!(value is OleDbCommand))
167 throw new ArgumentException ();
168 SelectCommand = (OleDbCommand)value;
172 MissingMappingAction IDataAdapter.MissingMappingAction {
173 get {
174 return missingMappingAction;
176 set {
177 missingMappingAction = value;
181 MissingSchemaAction IDataAdapter.MissingSchemaAction {
182 get {
183 return missingSchemaAction;
185 set {
186 missingSchemaAction = value;
190 IDbCommand IDbDataAdapter.UpdateCommand {
191 get {
192 return UpdateCommand;
194 set {
195 if (!(value is OleDbCommand))
196 throw new ArgumentException ();
197 UpdateCommand = (OleDbCommand)value;
201 ITableMappingCollection IDataAdapter.TableMappings {
202 get {
203 return TableMappings;
207 #endregion // Properties
209 #region Methods
211 protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow,
212 IDbCommand command,
213 StatementType statementType,
214 DataTableMapping tableMapping)
216 return new OleDbRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
220 protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow,
221 IDbCommand command,
222 StatementType statementType,
223 DataTableMapping tableMapping)
225 return new OleDbRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
228 protected override void OnRowUpdated (RowUpdatedEventArgs value)
230 if (RowUpdated != null)
231 RowUpdated (this, (OleDbRowUpdatedEventArgs) value);
234 protected override void OnRowUpdating (RowUpdatingEventArgs value)
236 if (RowUpdating != null)
237 RowUpdating (this, (OleDbRowUpdatingEventArgs) value);
240 [MonoTODO]
241 public int Fill(DataTable datatable, Object adoDBRecordSet) {
242 throw new NotImplementedException ();
245 [MonoTODO]
246 public int Fill(DataSet dataset, Object adoDBRecordSet, String srcTable) {
247 throw new NotImplementedException ();
250 #endregion // Methods
252 #region Events and Delegates
254 [DataSysDescription ("DbDataAdapter_RowUpdated")]
255 [DataCategory ("DataCategory_Update")]
256 public event OleDbRowUpdatedEventHandler RowUpdated;
258 [DataSysDescription ("DbDataAdapter_RowUpdating")]
259 [DataCategory ("DataCategory_Update")]
260 public event OleDbRowUpdatingEventHandler RowUpdating;
262 #endregion // Events and Delegates
264 [MonoTODO]
265 protected override void Dispose (bool disposing)
267 base.Dispose (disposing);