/// </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
{
#region Fields
+ const int DEFAULT_COMMAND_TIMEOUT = 30;
+
string commandText;
int timeout;
CommandType commandType;
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 ()
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;
}
[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
}
[DataCategory ("Data")]
- [DefaultValue ("Text")]
+ [DefaultValue ("Text")]
#if !NET_2_0
[DataSysDescriptionAttribute ("How to interpret the CommandText.")]
#endif
#if NET_2_0
override
#endif
- CommandType CommandType {
+ CommandType CommandType {
get {
return commandType;
}
#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;
}
[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;
}
}
[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;
}
#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;
}
}
}
}
- IDataParameterCollection IDbCommand.Parameters {
+ IDataParameterCollection IDbCommand.Parameters {
get {
return Parameters;
}
}
- IDbTransaction IDbCommand.Transaction {
+ IDbTransaction IDbCommand.Transaction {
get {
return Transaction;
}
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 ()
}
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
gdaParameterList);
}
- public OleDbDataReader ExecuteReader ()
+ public new OleDbDataReader ExecuteReader ()
{
- return ExecuteReader (CommandBehavior.Default);
+ return ExecuteReader (behavior);
}
IDataReader IDbCommand.ExecuteReader ()
return ExecuteReader ();
}
- public OleDbDataReader ExecuteReader (CommandBehavior behavior)
+ public new OleDbDataReader ExecuteReader (CommandBehavior behavior)
{
ArrayList results = new ArrayList ();
IntPtr rs_list;
break;
glist_node = (GdaList) Marshal.PtrToStructure (glist_node.next,
- typeof (GdaList));
+ typeof (GdaList));
}
dataReader = new OleDbDataReader (this, results);
dataReader.NextResult ();
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]
#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