merge r98600
[mono.git] / mcs / class / System.Data / System.Data.Odbc / OdbcDataAdapter.cs
old mode 100755 (executable)
new mode 100644 (file)
index c4b7afe..6e102bb
 // Copyright (C) 2002 Tim Coleman
 //
 
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
 using System;
 using System.ComponentModel;
 using System.Data;
@@ -19,11 +42,13 @@ namespace System.Data.Odbc {
        [DefaultEvent ("RowUpdated")]
        [DesignerAttribute ("Microsoft.VSDesigner.Data.VS.OdbcDataAdapterDesigner, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.ComponentModel.Design.IDesigner")]
        [ToolboxItemAttribute ("Microsoft.VSDesigner.Data.VS.OdbcDataAdapterToolboxItem, "+ Consts.AssemblyMicrosoft_VSDesigner)]
-       public sealed class OdbcDataAdapter : DbDataAdapter, IDbDataAdapter 
+       public sealed class OdbcDataAdapter : DbDataAdapter, IDbDataAdapter, ICloneable
        {
                #region Fields
 
-               bool disposed = false;  
+#if ONLY_1_1
+               bool disposed;
+#endif
                OdbcCommand deleteCommand;
                OdbcCommand insertCommand;
                OdbcCommand selectCommand;
@@ -33,17 +58,13 @@ namespace System.Data.Odbc {
 
                #region Constructors
                
-               public OdbcDataAdapter ()       
-                       : this (new OdbcCommand ())
+               public OdbcDataAdapter () : this ((OdbcCommand) null)
                {
                }
 
                public OdbcDataAdapter (OdbcCommand selectCommand) 
                {
-                       DeleteCommand = null;
-                       InsertCommand = null;
                        SelectCommand = selectCommand;
-                       UpdateCommand = null;
                }
 
                public OdbcDataAdapter (string selectCommandText, OdbcConnection selectConnection) 
@@ -64,7 +85,7 @@ namespace System.Data.Odbc {
                [OdbcDescription ("Used during Update for deleted rows in DataSet.")]
                [DefaultValue (null)]
                [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
-               public OdbcCommand DeleteCommand {
+               public new OdbcCommand DeleteCommand {
                        get { return deleteCommand; }
                        set { deleteCommand = value; }
                }
@@ -73,7 +94,7 @@ namespace System.Data.Odbc {
                [OdbcDescription ("Used during Update for new rows in DataSet.")]
                [DefaultValue (null)]
                [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
-               public OdbcCommand InsertCommand {
+               public new OdbcCommand InsertCommand {
                        get { return insertCommand; }
                        set { insertCommand = value; }
                }
@@ -82,7 +103,7 @@ namespace System.Data.Odbc {
                [OdbcDescription ("Used during Fill/FillSchema.")]
                [DefaultValue (null)]
                [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
-               public OdbcCommand SelectCommand {
+               public new OdbcCommand SelectCommand {
                        get { return selectCommand; }
                        set { selectCommand = value; }
                }
@@ -91,45 +112,29 @@ namespace System.Data.Odbc {
                [OdbcDescription ("Used during Update for modified rows in DataSet.")]
                [DefaultValue (null)]
                [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
-               public OdbcCommand UpdateCommand {
+               public new OdbcCommand UpdateCommand {
                        get { return updateCommand; }
                        set { updateCommand = value; }
                }
 
                IDbCommand IDbDataAdapter.DeleteCommand {
                        get { return DeleteCommand; }
-                       set { 
-                               if (!(value is OdbcCommand)) 
-                                       throw new ArgumentException ();
-                               DeleteCommand = (OdbcCommand)value;
-                       }
+                       set { DeleteCommand = (OdbcCommand) value; }
                }
 
                IDbCommand IDbDataAdapter.InsertCommand {
                        get { return InsertCommand; }
-                       set { 
-                               if (!(value is OdbcCommand)) 
-                                       throw new ArgumentException ();
-                               InsertCommand = (OdbcCommand)value;
-                       }
+                       set { InsertCommand = (OdbcCommand) value; }
                }
 
                IDbCommand IDbDataAdapter.SelectCommand {
                        get { return SelectCommand; }
-                       set { 
-                               if (!(value is OdbcCommand)) 
-                                       throw new ArgumentException ();
-                               SelectCommand = (OdbcCommand)value;
-                       }
+                       set { SelectCommand = (OdbcCommand) value; }
                }
 
                IDbCommand IDbDataAdapter.UpdateCommand {
                        get { return UpdateCommand; }
-                       set { 
-                               if (!(value is OdbcCommand)) 
-                                       throw new ArgumentException ();
-                               UpdateCommand = (OdbcCommand)value;
-                       }
+                       set { UpdateCommand = (OdbcCommand) value; }
                }
 
 
@@ -152,6 +157,7 @@ namespace System.Data.Odbc {
                        return new OdbcRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
                }
 
+#if ONLY_1_1
                protected override void Dispose (bool disposing)
                {
                        if (!disposed) {
@@ -161,7 +167,9 @@ namespace System.Data.Odbc {
                                // Release unmanaged resources
                                disposed = true;
                        }
+                       base.Dispose (true);
                }
+#endif
 
                protected override void OnRowUpdated (RowUpdatedEventArgs value) 
                {
@@ -175,6 +183,12 @@ namespace System.Data.Odbc {
                                RowUpdating (this, (OdbcRowUpdatingEventArgs) value);
                }
 
+               [MonoTODO]
+               object ICloneable.Clone ()
+               {
+                       throw new NotImplementedException ();
+               }
+
                #endregion // Methods
 
                #region Events and Delegates