//\r
// System.Data.SqlClient.SqlCommand\r
-//\r
-// Author:\r
-// Boris Kirzner (borisk@mainsoft.com)\r
-// Konstantin Triger (kostat@mainsoft.com)\r
+//
+// Authors:
+// Konstantin Triger <kostat@mainsoft.com>
+// Boris Kirzner <borisk@mainsoft.com>
+//
+// (C) 2005 Mainsoft Corporation (http://www.mainsoft.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;
using System.Data;
using System.Data.Common;
using System.Data.ProviderBase;
+using System.Xml;
using java.sql;
namespace System.Data.SqlClient
{
- public class SqlCommand : AbstractDbCommand, IDbCommand, IDisposable, ICloneable
+ public class SqlCommand : AbstractDbCommand
{
#region Fields
#region Properties
+ public override string CommandText {
+ get {
+ string commandText = base.CommandText;
+ if (CommandType != CommandType.StoredProcedure ||
+ string.IsNullOrEmpty (commandText) ||
+ commandText [0] == '[' ||
+ commandText.IndexOf ('.') >= 0)
+ return commandText;
+
+ string trimmedCommandText = commandText.TrimEnd ();
+ if (trimmedCommandText.Length > 0 && trimmedCommandText [trimmedCommandText.Length - 1] != ')')
+ commandText = String.Concat ("[", commandText, "]");
+
+ return commandText;
+ }
+ set {
+ base.CommandText = value;
+ }
+ }
+
public new SqlConnection Connection\r
{\r
get { return (SqlConnection)base.Connection; }\r
public new SqlParameterCollection Parameters\r
{\r
get { \r
- if (_parameters == null) {\r
- _parameters = CreateParameterCollection(this);\r
- }\r
- return (SqlParameterCollection)_parameters; \r
+ return (SqlParameterCollection)base.Parameters; \r
}\r
}
#region Methods
+ public XmlReader ExecuteXmlReader() {
+ return SqlXmlTextReader.Create(ExecuteReader(CommandBehavior.SequentialAccess));
+ }
+
public new SqlDataReader ExecuteReader()\r
{\r
return (SqlDataReader)ExecuteReader(CommandBehavior.Default);\r
return (SqlParameter)CreateParameterInternal();\r
}\r
\r
- protected override void CheckParameters()\r
+ protected sealed override void CheckParameters()\r
{\r
// do nothing\r
}\r
\r
for(int i=0; i < userParametersList.Count; i++) {\r
AbstractDbParameter userParameter = (AbstractDbParameter)userParametersList[i];\r
- if (String.Compare(parameterName, userParameter.ParameterName.Trim(), true) == 0) {\r
+ if (String.Compare(parameterName, userParameter.Placeholder.Trim(), true, System.Globalization.CultureInfo.InvariantCulture) == 0) {\r
return userParameter;\r
}\r
}\r
return null;\r
}\r
\r
- protected override DbParameter CreateParameterInternal()\r
+ protected override AbstractDbParameter GetReturnParameter (IList userParametersList)\r
{\r
- return new SqlParameter();\r
+ for(int i=0; i < userParametersList.Count; i++) {\r
+ AbstractDbParameter userParameter = (AbstractDbParameter)userParametersList[i];\r
+ if (userParameter.Direction == ParameterDirection.ReturnValue) {\r
+ return userParameter;\r
+ }\r
+ }\r
+\r
+ return null; \r
}\r
\r
- protected override DbDataReader CreateReader()\r
+ protected sealed override DbParameter CreateParameterInternal()\r
{\r
- return new SqlDataReader(this);\r
+ return new SqlParameter();\r
}\r
\r
- protected override DbParameterCollection CreateParameterCollection(AbstractDbCommand parent)\r
+ protected sealed override DbDataReader CreateReader()\r
{\r
- return new SqlParameterCollection((SqlCommand)parent);\r
+ return new SqlDataReader(this);\r
}\r
\r
- public object Clone()\r
+ protected sealed override DbParameterCollection CreateParameterCollection(AbstractDbCommand parent)\r
{\r
- SqlCommand clone = new SqlCommand();\r
- CopyTo(clone);\r
- return clone;\r
+ return new SqlParameterCollection((SqlCommand)parent);\r
}\r
\r
- protected override SystemException CreateException(SQLException e)
+ protected internal sealed override SystemException CreateException(SQLException e)
{\r
return new SqlException(e, Connection); \r
}
#endregion // Methods\r
}
-}
\ No newline at end of file
+}