2 // System.Data.Odbc.OdbcDataAdapter.cs
5 // Rodrigo Moya (rodrigo@ximian.com)
6 // Daniel Morgan (danmorg@sc.rr.com)
7 // Tim Coleman (tim@timcoleman.com)
9 // (C) Ximian, Inc 2002
10 // Copyright (C) 2002 Tim Coleman
14 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
16 // Permission is hereby granted, free of charge, to any person obtaining
17 // a copy of this software and associated documentation files (the
18 // "Software"), to deal in the Software without restriction, including
19 // without limitation the rights to use, copy, modify, merge, publish,
20 // distribute, sublicense, and/or sell copies of the Software, and to
21 // permit persons to whom the Software is furnished to do so, subject to
22 // the following conditions:
24 // The above copyright notice and this permission notice shall be
25 // included in all copies or substantial portions of the Software.
27 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 using System.ComponentModel;
39 using System.Data.Common;
41 namespace System.Data.Odbc {
42 [DefaultEvent ("RowUpdated")]
43 [DesignerAttribute ("Microsoft.VSDesigner.Data.VS.OdbcDataAdapterDesigner, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.ComponentModel.Design.IDesigner")]
44 [ToolboxItemAttribute ("Microsoft.VSDesigner.Data.VS.OdbcDataAdapterToolboxItem, "+ Consts.AssemblyMicrosoft_VSDesigner)]
45 public sealed class OdbcDataAdapter : DbDataAdapter, IDbDataAdapter, ICloneable
50 bool disposed = false;
52 OdbcCommand deleteCommand;
53 OdbcCommand insertCommand;
54 OdbcCommand selectCommand;
55 OdbcCommand updateCommand;
61 public OdbcDataAdapter () : this (new OdbcCommand ())
65 public OdbcDataAdapter (OdbcCommand selectCommand)
69 SelectCommand = selectCommand;
73 public OdbcDataAdapter (string selectCommandText, OdbcConnection selectConnection)
74 : this (new OdbcCommand (selectCommandText, selectConnection))
78 public OdbcDataAdapter (string selectCommandText, string selectConnectionString)
79 : this (selectCommandText, new OdbcConnection (selectConnectionString))
87 [OdbcCategory ("Update")]
88 [OdbcDescription ("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 new OdbcCommand DeleteCommand {
92 get { return deleteCommand; }
93 set { deleteCommand = value; }
96 [OdbcCategory ("Update")]
97 [OdbcDescription ("Used during Update for new rows in DataSet.")]
99 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
100 public new OdbcCommand InsertCommand {
101 get { return insertCommand; }
102 set { insertCommand = value; }
105 [OdbcCategory ("Fill")]
106 [OdbcDescription ("Used during Fill/FillSchema.")]
107 [DefaultValue (null)]
108 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
109 public new OdbcCommand SelectCommand {
110 get { return selectCommand; }
111 set { selectCommand = value; }
114 [OdbcCategory ("Update")]
115 [OdbcDescription ("Used during Update for modified rows in DataSet.")]
116 [DefaultValue (null)]
117 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
118 public new OdbcCommand UpdateCommand {
119 get { return updateCommand; }
120 set { updateCommand = value; }
123 IDbCommand IDbDataAdapter.DeleteCommand {
124 get { return DeleteCommand; }
126 if (!(value is OdbcCommand))
127 throw new ArgumentException ();
128 DeleteCommand = (OdbcCommand)value;
132 IDbCommand IDbDataAdapter.InsertCommand {
133 get { return InsertCommand; }
135 if (!(value is OdbcCommand))
136 throw new ArgumentException ();
137 InsertCommand = (OdbcCommand)value;
141 IDbCommand IDbDataAdapter.SelectCommand {
142 get { return SelectCommand; }
144 if (!(value is OdbcCommand))
145 throw new ArgumentException ();
146 SelectCommand = (OdbcCommand)value;
150 IDbCommand IDbDataAdapter.UpdateCommand {
151 get { return UpdateCommand; }
153 if (!(value is OdbcCommand))
154 throw new ArgumentException ();
155 UpdateCommand = (OdbcCommand)value;
160 ITableMappingCollection IDataAdapter.TableMappings {
161 get { return TableMappings; }
164 #endregion // Properties
168 protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
170 return new OdbcRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
174 protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
176 return new OdbcRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
180 protected override void Dispose (bool disposing)
184 // Release managed resources
186 // Release unmanaged resources
192 protected override void OnRowUpdated (RowUpdatedEventArgs value)
194 if (RowUpdated != null)
195 RowUpdated (this, (OdbcRowUpdatedEventArgs) value);
198 protected override void OnRowUpdating (RowUpdatingEventArgs value)
200 if (RowUpdating != null)
201 RowUpdating (this, (OdbcRowUpdatingEventArgs) value);
205 object ICloneable.Clone ()
207 throw new NotImplementedException ();
210 #endregion // Methods
212 #region Events and Delegates
214 public event OdbcRowUpdatedEventHandler RowUpdated;
215 public event OdbcRowUpdatingEventHandler RowUpdating;
217 #endregion // Events and Delegates