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
43 [DefaultEvent ("RowUpdated")]
44 [DesignerAttribute ("Microsoft.VSDesigner.Data.VS.OdbcDataAdapterDesigner, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.ComponentModel.Design.IDesigner")]
45 [ToolboxItemAttribute ("Microsoft.VSDesigner.Data.VS.OdbcDataAdapterToolboxItem, "+ Consts.AssemblyMicrosoft_VSDesigner)]
46 public sealed class OdbcDataAdapter : DbDataAdapter, IDbDataAdapter, ICloneable
53 OdbcCommand deleteCommand;
54 OdbcCommand insertCommand;
55 OdbcCommand selectCommand;
56 OdbcCommand updateCommand;
62 public OdbcDataAdapter () : this ((OdbcCommand) null)
66 public OdbcDataAdapter (OdbcCommand selectCommand)
68 SelectCommand = selectCommand;
71 public OdbcDataAdapter (string selectCommandText, OdbcConnection selectConnection)
72 : this (new OdbcCommand (selectCommandText, selectConnection))
76 public OdbcDataAdapter (string selectCommandText, string selectConnectionString)
77 : this (selectCommandText, new OdbcConnection (selectConnectionString))
85 [OdbcCategory ("Update")]
86 [OdbcDescription ("Used during Update for deleted rows in DataSet.")]
88 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
89 public new OdbcCommand DeleteCommand {
90 get { return deleteCommand; }
91 set { deleteCommand = value; }
94 [OdbcCategory ("Update")]
95 [OdbcDescription ("Used during Update for new rows in DataSet.")]
97 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
98 public new OdbcCommand InsertCommand {
99 get { return insertCommand; }
100 set { insertCommand = value; }
103 [OdbcCategory ("Fill")]
104 [OdbcDescription ("Used during Fill/FillSchema.")]
105 [DefaultValue (null)]
106 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
107 public new OdbcCommand SelectCommand {
108 get { return selectCommand; }
109 set { selectCommand = value; }
112 [OdbcCategory ("Update")]
113 [OdbcDescription ("Used during Update for modified rows in DataSet.")]
114 [DefaultValue (null)]
115 [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
116 public new OdbcCommand UpdateCommand {
117 get { return updateCommand; }
118 set { updateCommand = value; }
121 IDbCommand IDbDataAdapter.DeleteCommand {
122 get { return DeleteCommand; }
123 set { DeleteCommand = (OdbcCommand) value; }
126 IDbCommand IDbDataAdapter.InsertCommand {
127 get { return InsertCommand; }
128 set { InsertCommand = (OdbcCommand) value; }
131 IDbCommand IDbDataAdapter.SelectCommand {
132 get { return SelectCommand; }
133 set { SelectCommand = (OdbcCommand) value; }
136 IDbCommand IDbDataAdapter.UpdateCommand {
137 get { return UpdateCommand; }
138 set { UpdateCommand = (OdbcCommand) value; }
141 #endregion // Properties
145 protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
147 return new OdbcRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
151 protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
153 return new OdbcRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
157 protected override void Dispose (bool disposing)
161 // Release managed resources
163 // Release unmanaged resources
170 protected override void OnRowUpdated (RowUpdatedEventArgs value)
172 if (RowUpdated != null)
173 RowUpdated (this, (OdbcRowUpdatedEventArgs) value);
176 protected override void OnRowUpdating (RowUpdatingEventArgs value)
178 if (RowUpdating != null)
179 RowUpdating (this, (OdbcRowUpdatingEventArgs) value);
183 object ICloneable.Clone ()
185 throw new NotImplementedException ();
188 #endregion // Methods
190 #region Events and Delegates
192 public event OdbcRowUpdatedEventHandler RowUpdated;
193 public event OdbcRowUpdatingEventHandler RowUpdating;
195 #endregion // Events and Delegates