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
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")]
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
{
96 deleteCommand
= value;
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
{
106 return insertCommand
;
109 insertCommand
= value;
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
{
119 return selectCommand
;
122 selectCommand
= value;
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
{
132 return updateCommand
;
135 updateCommand
= value;
139 IDbCommand IDbDataAdapter
.DeleteCommand
{
141 return DeleteCommand
;
144 if (!(value is OleDbCommand
))
145 throw new ArgumentException ();
146 DeleteCommand
= (OleDbCommand
)value;
150 IDbCommand IDbDataAdapter
.InsertCommand
{
152 return InsertCommand
;
155 if (!(value is OleDbCommand
))
156 throw new ArgumentException ();
157 InsertCommand
= (OleDbCommand
)value;
161 IDbCommand IDbDataAdapter
.SelectCommand
{
163 return SelectCommand
;
166 if (!(value is OleDbCommand
))
167 throw new ArgumentException ();
168 SelectCommand
= (OleDbCommand
)value;
172 MissingMappingAction IDataAdapter
.MissingMappingAction
{
174 return missingMappingAction
;
177 missingMappingAction
= value;
181 MissingSchemaAction IDataAdapter
.MissingSchemaAction
{
183 return missingSchemaAction
;
186 missingSchemaAction
= value;
190 IDbCommand IDbDataAdapter
.UpdateCommand
{
192 return UpdateCommand
;
195 if (!(value is OleDbCommand
))
196 throw new ArgumentException ();
197 UpdateCommand
= (OleDbCommand
)value;
201 ITableMappingCollection IDataAdapter
.TableMappings
{
203 return TableMappings
;
207 #endregion // Properties
211 protected override RowUpdatedEventArgs
CreateRowUpdatedEvent (DataRow dataRow
,
213 StatementType statementType
,
214 DataTableMapping tableMapping
)
216 return new OleDbRowUpdatedEventArgs (dataRow
, command
, statementType
, tableMapping
);
220 protected override RowUpdatingEventArgs
CreateRowUpdatingEvent (DataRow dataRow
,
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);
241 public int Fill(DataTable datatable
, Object adoDBRecordSet
) {
242 throw new NotImplementedException ();
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
265 protected override void Dispose (bool disposing
)
267 base.Dispose (disposing
);