// Copyright (C) Tim Coleman, 2002
//
+//
+// 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.ComponentModel;
using System.Data;
using System.Data.Common;
/// <summary>
/// Represents an SQL statement or stored procedure to execute against a data source.
/// </summary>
- public sealed class OleDbCommand : Component, ICloneable, IDbCommand
+ [DesignerAttribute ("Microsoft.VSDesigner.Data.VS.OleDbCommandDesigner, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.ComponentModel.Design.IDesigner")]
+ [ToolboxItemAttribute ("System.Drawing.Design.ToolboxItem, "+ Consts.AssemblySystem_Drawing)]
+ public sealed class OleDbCommand :
+#if NET_2_0
+ DbCommand
+#else
+ Component
+#endif
+ , ICloneable, IDbCommand
{
#region Fields
#region Properties
- public string CommandText
+ [DataCategory ("Data")]
+ [DefaultValue ("")]
+#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
+#if NET_2_0
+ override
+#endif
+ string CommandText
{
get {
return commandText;
}
}
- public int CommandTimeout {
+#if !NET_2_0
+ [DataSysDescriptionAttribute ("Time to wait for command to execute.")]
+#endif
+ [DefaultValue (30)]
+ public
+#if NET_2_0
+ override
+#endif
+ int CommandTimeout {
get {
return timeout;
}
}
}
- public CommandType CommandType {
+ [DataCategory ("Data")]
+ [DefaultValue ("Text")]
+#if !NET_2_0
+ [DataSysDescriptionAttribute ("How to interpret the CommandText.")]
+#endif
+ [RefreshPropertiesAttribute (RefreshProperties.All)]
+ public
+#if NET_2_0
+ override
+#endif
+ CommandType CommandType {
get {
return commandType;
}
}
}
+ [DataCategory ("Behavior")]
+#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 {
get {
return connection;
connection = value;
}
}
-
- public bool DesignTimeVisible {
+
+ [BrowsableAttribute (false)]
+ [DesignOnlyAttribute (true)]
+ [DefaultValue (true)]
+ public
+#if NET_2_0
+ override
+#endif
+ bool DesignTimeVisible {
get {
return designTimeVisible;
}
}
}
+ [DataCategory ("Data")]
+#if !NET_2_0
+ [DataSysDescriptionAttribute ("The parameters collection.")]
+#endif
+ [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
public OleDbParameterCollection Parameters {
get {
return parameters;
}
- set {
- parameters = value;
- }
}
-
+
+ [BrowsableAttribute (false)]
+#if !NET_2_0
+ [DataSysDescriptionAttribute ("The transaction used by the command.")]
+#endif
+ [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
public OleDbTransaction Transaction {
get {
return transaction;
}
}
- public UpdateRowSource UpdatedRowSource {
+ [DataCategory ("Behavior")]
+ [DefaultValue (UpdateRowSource.Both)]
+#if !NET_2_0
+ [DataSysDescriptionAttribute ("When used by a DataAdapter.Update, how command results are applied to the current DataRow.")]
+#endif
+ public
+#if NET_2_0
+ override
+#endif
+ UpdateRowSource UpdatedRowSource {
[MonoTODO]
get {
throw new NotImplementedException ();
#region Methods
[MonoTODO]
- public void Cancel ()
+ public
+#if NET_2_0
+ override
+#endif
+ void Cancel ()
{
throw new NotImplementedException ();
}
//libgda.gda_command_set_transaction
}
-
- public int ExecuteNonQuery ()
+ public
+#if NET_2_0
+ override
+#endif
+ int ExecuteNonQuery ()
{
if (connection == null)
- throw new InvalidOperationException ();
+ throw new InvalidOperationException ("connection == null");
if (connection.State == ConnectionState.Closed)
- throw new InvalidOperationException ();
+ throw new InvalidOperationException ("State == Closed");
// FIXME: a third check is mentioned in .NET docs
- if (connection.DataReader != null)
- throw new InvalidOperationException ();
IntPtr gdaConnection = connection.GdaConnection;
IntPtr gdaParameterList = parameters.GdaParameterList;
GdaList glist_node;
if (connection.State != ConnectionState.Open)
- throw new InvalidOperationException ();
- if (connection.DataReader != null)
- throw new InvalidOperationException ();
+ throw new InvalidOperationException ("State != Open");
this.behavior = behavior;
return ExecuteReader (behavior);
}
- public object ExecuteScalar ()
+ public
+#if NET_2_0
+ override
+#endif
+ object ExecuteScalar ()
{
- if (connection.DataReader != null)
- throw new InvalidOperationException ();
-
SetupGdaCommand ();
OleDbDataReader reader = ExecuteReader ();
- return reader.GetValue (0);
+ if (reader == null) {
+ return null;
+ }
+ if (!reader.Read ()) {
+ reader.Close ();
+ return null;
+ }
+ object o = reader.GetValue (0);
+ reader.Close ();
+ return o;
}
[MonoTODO]
}
[MonoTODO]
- public void Prepare ()
+ public
+#if NET_2_0
+ override
+#endif
+ void Prepare ()
{
throw new NotImplementedException ();
}
{
timeout = 30;
}
+
+#if NET_2_0
+ [MonoTODO]
+ protected override DbParameter CreateDbParameter ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected override DbDataReader ExecuteDbDataReader (CommandBehavior behavior)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected override DbConnection DbConnection {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ protected override DbParameterCollection DbParameterCollection {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ protected override DbTransaction DbTransaction {
+ get { throw new NotImplementedException (); }
+ set { throw new NotImplementedException (); }
+ }
+#endif
#endregion
}