Update VS project files
[mono.git] / mcs / class / System.Data / System.Data.OleDb / OleDbCommand.cs
index 734b6487909a078aa3d85564afb3443f7be33ac2..585c7d7ffb690380d53075824d60939629adb03e 100644 (file)
@@ -45,6 +45,9 @@ 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
        DbCommand
@@ -55,6 +58,8 @@ namespace System.Data.OleDb
        {
                #region Fields
 
+               const int DEFAULT_COMMAND_TIMEOUT = 30;
+
                string commandText;
                int timeout;
                CommandType commandType;
@@ -65,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 ()
@@ -95,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;
                }
@@ -109,28 +113,29 @@ namespace System.Data.OleDb
                [DataCategory ("Data")]
                [DefaultValue ("")]
 #if !NET_2_0
-                [DataSysDescriptionAttribute ("Command text to execute.")]
+               [DataSysDescriptionAttribute ("Command text to execute.")]
 #endif
-                [EditorAttribute ("Microsoft.VSDesigner.Data.ADO.Design.OleDbCommandTextEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
+               [EditorAttribute ("Microsoft.VSDesigner.Data.ADO.Design.OleDbCommandTextEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing)]
                [RefreshPropertiesAttribute (RefreshProperties.All)]
                public 
 #if NET_2_0
                override
 #endif
-               string CommandText 
-               {
+               string CommandText {
                        get {
+                               if (commandText == null)
+                                       return string.Empty;
                                return commandText;
                        }
-                       set { 
+                       set {
                                commandText = value;
                        }
                }
 
 #if !NET_2_0
                [DataSysDescriptionAttribute ("Time to wait for command to execute.")]
+               [DefaultValue (DEFAULT_COMMAND_TIMEOUT)]
 #endif
-               [DefaultValue (30)]
                public
 #if NET_2_0
                override
@@ -145,7 +150,7 @@ namespace System.Data.OleDb
                }
 
                [DataCategory ("Data")]
-                [DefaultValue ("Text")]
+               [DefaultValue ("Text")]
 #if !NET_2_0
                [DataSysDescriptionAttribute ("How to interpret the CommandText.")]
 #endif
@@ -154,7 +159,7 @@ namespace System.Data.OleDb
 #if NET_2_0
                override
 #endif
-               CommandType CommandType { 
+               CommandType CommandType {
                        get {
                                return commandType;
                        }
@@ -169,7 +174,7 @@ namespace System.Data.OleDb
 #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;
                        }
@@ -181,11 +186,14 @@ namespace System.Data.OleDb
                [BrowsableAttribute (false)]
                [DesignOnlyAttribute (true)]
                [DefaultValue (true)]
+#if NET_2_0
+               [EditorBrowsable(EditorBrowsableState.Never)]
+#endif
                public
 #if NET_2_0
                override
 #endif
-               bool DesignTimeVisible { 
+               bool DesignTimeVisible {
                        get {
                                return designTimeVisible;
                        }
@@ -195,22 +203,21 @@ namespace System.Data.OleDb
                }
 
                [DataCategory ("Data")]
-#if !NET_2_0
+#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)]
-#if !NET_2_0
+#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;
                        }
@@ -224,18 +231,16 @@ namespace System.Data.OleDb
 #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 { 
-                       [MonoTODO]
-                       get {
-                               throw new NotImplementedException ();
-                       }
-                       [MonoTODO]
+               UpdateRowSource UpdatedRowSource {
+                       get { return updatedRowSource; }
                        set {
-                               throw new NotImplementedException ();
+                               ExceptionHelper.CheckEnumValue (typeof (UpdateRowSource), value);
+                               updatedRowSource = value;
                        }
                }
 
@@ -248,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;
                        }
@@ -277,20 +282,26 @@ namespace System.Data.OleDb
                        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 ()
@@ -311,14 +322,15 @@ 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 
 #if NET_2_0
                override
@@ -340,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 ()
@@ -350,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;
@@ -379,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 ();
@@ -413,10 +425,27 @@ 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]
@@ -426,42 +455,37 @@ namespace System.Data.OleDb
 #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