Update VS project files
[mono.git] / mcs / class / System.Data / System.Data.OleDb / OleDbCommand.cs
index efe4d6ed0f75af5a6ad2c64bcdc6065f25bbf38e..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 ;
                        parameters = new OleDbParameterCollection ();
-                       transaction;
-                       designTimeVisible;
-                       dataReader;
                        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;
                }
@@ -117,20 +121,21 @@ namespace System.Data.OleDb
 #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
@@ -181,6 +186,9 @@ namespace System.Data.OleDb
                [BrowsableAttribute (false)]
                [DesignOnlyAttribute (true)]
                [DefaultValue (true)]
+#if NET_2_0
+               [EditorBrowsable(EditorBrowsableState.Never)]
+#endif
                public
 #if NET_2_0
                override
@@ -195,18 +203,17 @@ namespace System.Data.OleDb
                }
 
                [DataCategory ("Data")]
-#if !NET_2_0
+#if ONLY_1_1
                [DataSysDescriptionAttribute ("The parameters collection.")]
 #endif
                [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
                public new OleDbParameterCollection Parameters {
-                       get {
-                               return 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)]
@@ -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]
+                       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;
                        }
@@ -282,15 +287,21 @@ namespace System.Data.OleDb
                        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,10 +322,10 @@ 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 
@@ -380,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 ();
@@ -414,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]
@@ -432,37 +460,32 @@ namespace System.Data.OleDb
 
                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