Update VS project files
[mono.git] / mcs / class / System.Data / System.Data.OleDb / OleDbCommand.cs
index 6ea3570d70a0eec5b6c0cf603a1d530fc770ed68..585c7d7ffb690380d53075824d60939629adb03e 100644 (file)
@@ -38,11 +38,6 @@ using System.Data.Common;
 using System.Collections;
 using System.Runtime.InteropServices;
 
-#if NET_2_0
-using System.Data.ProviderBase;
-using System.Data;
-#endif
-
 namespace System.Data.OleDb
 {
        /// <summary>
@@ -50,9 +45,12 @@ namespace System.Data.OleDb
        /// </summary>
        [DesignerAttribute ("Microsoft.VSDesigner.Data.VS.OleDbCommandDesigner, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.ComponentModel.Design.IDesigner")]
        [ToolboxItemAttribute ("System.Drawing.Design.ToolboxItem, "+ Consts.AssemblySystem_Drawing)]
+#if NET_2_0
+       [DefaultEvent( "RecordsAffected")]
+#endif
        public sealed class OleDbCommand : 
 #if NET_2_0
-       DbCommandBase
+       DbCommand
 #else
        Component
 #endif
@@ -60,6 +58,8 @@ namespace System.Data.OleDb
        {
                #region Fields
 
+               const int DEFAULT_COMMAND_TIMEOUT = 30;
+
                string commandText;
                int timeout;
                CommandType commandType;
@@ -70,23 +70,23 @@ namespace System.Data.OleDb
                OleDbDataReader dataReader;
                CommandBehavior behavior;
                IntPtr gdaCommand;
+               UpdateRowSource updatedRowSource;
 
+               bool disposed;
+               
                #endregion // Fields
 
                #region Constructors
 
                public OleDbCommand ()
-               {
-                       commandText = String.Empty;
-                       timeout = 30; // default timeout per .NET
+               {
+                       timeout = DEFAULT_COMMAND_TIMEOUT;
                        commandType = CommandType.Text;
-                       connection = null;
                        parameters = new OleDbParameterCollection ();
-                       transaction = null;
-                       designTimeVisible = false;
-                       dataReader = null;
                        behavior = CommandBehavior.Default;
                        gdaCommand = IntPtr.Zero;
+                       designTimeVisible = true;
+                       this.updatedRowSource = UpdateRowSource.Both;
                }
 
                public OleDbCommand (string cmdText) : this ()
@@ -100,9 +100,8 @@ namespace System.Data.OleDb
                        Connection = connection;
                }
 
-               public OleDbCommand (string cmdText,
-                                    OleDbConnection connection,
-                                    OleDbTransaction transaction) : this (cmdText, connection)
+               public OleDbCommand (string cmdText, OleDbConnection connection,
+                       OleDbTransaction transaction) : this (cmdText, connection)
                {
                        this.transaction = transaction;
                }
@@ -113,22 +112,35 @@ namespace System.Data.OleDb
        
                [DataCategory ("Data")]
                [DefaultValue ("")]
-                [DataSysDescriptionAttribute ("Command text to execute")]
-                [EditorAttribute ("Microsoft.VSDesigner.Data.ADO.Design.OleDbCommandTextEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
+#if !NET_2_0
+               [DataSysDescriptionAttribute ("Command text to execute.")]
+#endif
+               [EditorAttribute ("Microsoft.VSDesigner.Data.ADO.Design.OleDbCommandTextEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing)]
                [RefreshPropertiesAttribute (RefreshProperties.All)]
-               public string CommandText 
-               {
+               public 
+#if NET_2_0
+               override
+#endif
+               string CommandText {
                        get {
+                               if (commandText == null)
+                                       return string.Empty;
                                return commandText;
                        }
-                       set { 
+                       set {
                                commandText = value;
                        }
                }
 
-               [DataSysDescriptionAttribute ("Time to wait for command to execute")]
-               [DefaultValue (30)]
-               public int CommandTimeout {
+#if !NET_2_0
+               [DataSysDescriptionAttribute ("Time to wait for command to execute.")]
+               [DefaultValue (DEFAULT_COMMAND_TIMEOUT)]
+#endif
+               public
+#if NET_2_0
+               override
+#endif
+               int CommandTimeout {
                        get {
                                return timeout;
                        }
@@ -138,10 +150,16 @@ namespace System.Data.OleDb
                }
 
                [DataCategory ("Data")]
-                [DefaultValue ("Text")]
-               [DataSysDescriptionAttribute ("How to interpret the CommandText")]
+               [DefaultValue ("Text")]
+#if !NET_2_0
+               [DataSysDescriptionAttribute ("How to interpret the CommandText.")]
+#endif
                [RefreshPropertiesAttribute (RefreshProperties.All)]
-               public CommandType CommandType { 
+               public
+#if NET_2_0
+               override
+#endif
+               CommandType CommandType {
                        get {
                                return commandType;
                        }
@@ -151,10 +169,12 @@ namespace System.Data.OleDb
                }
 
                [DataCategory ("Behavior")]
-               [DataSysDescriptionAttribute ("Connection used by the command")]
+#if !NET_2_0
+               [DataSysDescriptionAttribute ("Connection used by the command.")]
+#endif
                [DefaultValue (null)]
                [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DbConnectionEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
-               public OleDbConnection Connection { 
+               public new OleDbConnection Connection {
                        get {
                                return connection;
                        }
@@ -166,7 +186,14 @@ namespace System.Data.OleDb
                [BrowsableAttribute (false)]
                [DesignOnlyAttribute (true)]
                [DefaultValue (true)]
-               public bool DesignTimeVisible { 
+#if NET_2_0
+               [EditorBrowsable(EditorBrowsableState.Never)]
+#endif
+               public
+#if NET_2_0
+               override
+#endif
+               bool DesignTimeVisible {
                        get {
                                return designTimeVisible;
                        }
@@ -176,18 +203,21 @@ namespace System.Data.OleDb
                }
 
                [DataCategory ("Data")]
-               [DataSysDescriptionAttribute ("The parameters collection")]
+#if ONLY_1_1
+               [DataSysDescriptionAttribute ("The parameters collection.")]
+#endif
                [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
-               public OleDbParameterCollection Parameters {
-                       get {
-                               return parameters;
-                       }
+               public new OleDbParameterCollection Parameters {
+                       get { return parameters; }
+                       internal set { parameters = value; }
                }
-               
+
                [BrowsableAttribute (false)]
-               [DataSysDescriptionAttribute ("The transaction used by the command")]
+#if ONLY_1_1
+               [DataSysDescriptionAttribute ("The transaction used by the command.")]
+#endif
                [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
-               public OleDbTransaction Transaction {
+               public new OleDbTransaction Transaction {
                        get {
                                return transaction;
                        }
@@ -198,15 +228,19 @@ namespace System.Data.OleDb
 
                [DataCategory ("Behavior")]
                [DefaultValue (UpdateRowSource.Both)]
-               [DataSysDescriptionAttribute ("When used by a DataAdapter.Update, how command results are applied to the current DataRow")]
-               public UpdateRowSource UpdatedRowSource { 
-                       [MonoTODO]
-                       get {
-                               throw new NotImplementedException ();
-                       }
-                       [MonoTODO]
+#if !NET_2_0
+               [DataSysDescriptionAttribute ("When used by a DataAdapter.Update, how command results are applied to the current DataRow.")]
+#endif
+               [MonoTODO]
+               public
+#if NET_2_0
+               override
+#endif
+               UpdateRowSource UpdatedRowSource {
+                       get { return updatedRowSource; }
                        set {
-                               throw new NotImplementedException ();
+                               ExceptionHelper.CheckEnumValue (typeof (UpdateRowSource), value);
+                               updatedRowSource = value;
                        }
                }
 
@@ -219,13 +253,13 @@ namespace System.Data.OleDb
                        }
                }
 
-               IDataParameterCollection IDbCommand.Parameters  {
+               IDataParameterCollection IDbCommand.Parameters {
                        get {
                                return Parameters;
                        }
                }
 
-               IDbTransaction IDbCommand.Transaction  {
+               IDbTransaction IDbCommand.Transaction {
                        get {
                                return Transaction;
                        }
@@ -239,25 +273,35 @@ namespace System.Data.OleDb
                #region Methods
 
                [MonoTODO]
-               public void Cancel () 
+               public 
+#if NET_2_0
+               override 
+#endif
+               void Cancel () 
                {
                        throw new NotImplementedException ();
                }
 
-               public OleDbParameter CreateParameter ()
+               public new OleDbParameter CreateParameter ()
                {
                        return new OleDbParameter ();
                }
 
+#if !NET_2_0
                IDbDataParameter IDbCommand.CreateParameter ()
                {
                        return CreateParameter ();
                }
+#endif
                
-               [MonoTODO]
                protected override void Dispose (bool disposing)
                {
-                       throw new NotImplementedException ();
+                       if (disposed)
+                               return;
+                       
+                       Connection = null;
+                       Transaction = null;
+                       disposed = true;
                }
 
                private void SetupGdaCommand ()
@@ -278,16 +322,20 @@ namespace System.Data.OleDb
                        }
                        
                        if (gdaCommand != IntPtr.Zero) {
-                               libgda.gda_command_set_text (gdaCommand, commandText);
+                               libgda.gda_command_set_text (gdaCommand, CommandText);
                                libgda.gda_command_set_command_type (gdaCommand, type);
                        } else {
-                               gdaCommand = libgda.gda_command_new (commandText, type, 0);
+                               gdaCommand = libgda.gda_command_new (CommandText, type, 0);
                        }
 
                        //libgda.gda_command_set_transaction 
                }
-               
-               public int ExecuteNonQuery ()
+
+               public 
+#if NET_2_0
+               override
+#endif
+               int ExecuteNonQuery ()
                {
                        if (connection == null)
                                throw new InvalidOperationException ("connection == null");
@@ -304,9 +352,9 @@ namespace System.Data.OleDb
                                                                        gdaParameterList);
                }
 
-               public OleDbDataReader ExecuteReader ()
+               public new OleDbDataReader ExecuteReader ()
                {
-                       return ExecuteReader (CommandBehavior.Default);
+                       return ExecuteReader (behavior);
                }
 
                IDataReader IDbCommand.ExecuteReader ()
@@ -314,7 +362,7 @@ namespace System.Data.OleDb
                        return ExecuteReader ();
                }
 
-               public OleDbDataReader ExecuteReader (CommandBehavior behavior)
+               public new OleDbDataReader ExecuteReader (CommandBehavior behavior)
                {
                        ArrayList results = new ArrayList ();
                        IntPtr rs_list;
@@ -343,7 +391,7 @@ namespace System.Data.OleDb
                                                break;
 
                                        glist_node = (GdaList) Marshal.PtrToStructure (glist_node.next,
-                                                                                      typeof (GdaList));
+                                               typeof (GdaList));
                                }
                                dataReader = new OleDbDataReader (this, results);
                                dataReader.NextResult ();
@@ -357,7 +405,11 @@ namespace System.Data.OleDb
                        return ExecuteReader (behavior);
                }
                
-               public object ExecuteScalar ()
+               public
+#if NET_2_0
+               override
+#endif
+               object ExecuteScalar ()
                {
                        SetupGdaCommand ();
                        OleDbDataReader reader = ExecuteReader ();
@@ -373,51 +425,67 @@ namespace System.Data.OleDb
                        return o;
                }
 
-               [MonoTODO]
+#if NET_2_0
+               public
+#else
+               internal
+#endif
+               OleDbCommand Clone ()
+               {
+                       OleDbCommand command = new OleDbCommand ();
+                       command.CommandText = this.CommandText;
+                       command.CommandTimeout = this.CommandTimeout;
+                       command.CommandType = this.CommandType;
+                       command.Connection = this.Connection;
+                       command.DesignTimeVisible = this.DesignTimeVisible;
+                       command.Parameters = this.Parameters;
+                       command.Transaction = this.Transaction;
+                       return command;
+               }
+
                object ICloneable.Clone ()
                {
-                       throw new NotImplementedException ();   
+                       return Clone ();
                }
 
                [MonoTODO]
-               public void Prepare ()
+               public 
+#if NET_2_0
+               override
+#endif
+               void Prepare ()
                {
-                       throw new NotImplementedException ();   
+                       throw new NotImplementedException ();
                }
 
                public void ResetCommandTimeout ()
                {
-                       timeout = 30;
+                       timeout = DEFAULT_COMMAND_TIMEOUT;
                }
                
 #if NET_2_0
-               [MonoTODO]
                protected override DbParameter CreateDbParameter ()
                {
-                       throw new NotImplementedException ();   
+                       return (DbParameter) CreateParameter ();
                }
                
-               [MonoTODO]
                protected override DbDataReader ExecuteDbDataReader (CommandBehavior behavior)
                {
-                       throw new NotImplementedException ();   
+                       return (DbDataReader) ExecuteReader (behavior);
                }
                
-               [MonoTODO]
                protected override DbConnection DbConnection {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return Connection; }
+                       set { Connection = (OleDbConnection) value; }
                }
                
-               [MonoTODO]
                protected override DbParameterCollection DbParameterCollection {
-                       get { throw new NotImplementedException (); }
+                       get { return Parameters; }
                }
                
-               [MonoTODO]
                protected override DbTransaction DbTransaction {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return Transaction; }
+                       set { Transaction = (OleDbTransaction) value; }
                }
 #endif