2 // System.Data.ProviderBase.DbCommandBase
5 // Tim Coleman (tim@timcoleman.com)
6 // Boris Kirzner (borisk@mainsoft.com)
8 // Copyright (C) Tim Coleman, 2003
12 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
13 // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
15 // Permission is hereby granted, free of charge, to any person obtaining
16 // a copy of this software and associated documentation files (the
17 // "Software"), to deal in the Software without restriction, including
18 // without limitation the rights to use, copy, modify, merge, publish,
19 // distribute, sublicense, and/or sell copies of the Software, and to
20 // permit persons to whom the Software is furnished to do so, subject to
21 // the following conditions:
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 #if NET_2_0 || TARGET_JVM
37 using System.Data.Common;
39 namespace System.Data.ProviderBase {
40 public abstract class DbCommandBase : DbCommand
46 CommandType _commandType;
47 bool _designTimeVisible;
48 UpdateRowSource _updatedRowSource;
54 protected DbCommandBase ()
56 _commandText = String.Empty;
58 _commandType = CommandType.Text;
59 _designTimeVisible = true;
60 _updatedRowSource = UpdateRowSource.Both;
63 protected DbCommandBase (DbCommandBase from)
65 _commandText = from._commandText;
66 _commandTimeout = from._commandTimeout;
67 _commandType = from._commandType;
68 _updatedRowSource = from._updatedRowSource;
69 _designTimeVisible = from._designTimeVisible;
72 #endregion // Constructors
76 public override string CommandText {
77 get { return _commandText; }
78 set { _commandText = value; }
80 public override int CommandTimeout {
81 get { return _commandTimeout; }
82 set { _commandTimeout = value; }
85 public override CommandType CommandType {
86 get { return _commandType; }
87 set { _commandType = value; }
90 public override bool DesignTimeVisible {
91 get { return _designTimeVisible; }
92 set { _designTimeVisible = value; }
95 public override UpdateRowSource UpdatedRowSource {
96 get { return _updatedRowSource; }
97 set { _updatedRowSource = value; }
100 #endregion // Properties
105 public override void Cancel ()
107 throw new NotImplementedException ();
111 public override int ExecuteNonQuery ()
113 IDataReader reader = null;
115 reader = ExecuteReader ();
121 return reader.RecordsAffected;
124 public override object ExecuteScalar ()
126 IDataReader reader = ExecuteReader(CommandBehavior.SingleRow | CommandBehavior.SequentialAccess);
130 if (reader.FieldCount > 0 && reader.Read ())
131 return reader.GetValue (0);
133 while (reader.NextResult ());
141 public override void Prepare ()
143 throw new NotImplementedException ();
146 public virtual void PropertyChanging ()
150 public virtual void ResetCommandTimeout ()
152 _commandTimeout = 30;
156 protected internal static void SetInputParameterValues (DbCommand command, object[] inputParameterValues)
158 throw new NotImplementedException ();
161 #endregion // Methods