Copy from 72246 to trunk
[mono.git] / mcs / class / System.Data / System.Data.SqlClient.jvm / SqlCommand.cs
index a9ff349fb59a4bd8cb70546896414487805dd81c..572097940a92caac9486ed95fcd6af2962a7f3ff 100644 (file)
@@ -36,6 +36,7 @@ using System.Text.RegularExpressions;
 using System.Data;
 using System.Data.Common;
 using System.Data.ProviderBase;
+using System.Xml;
 
 using java.sql;
 
@@ -83,6 +84,26 @@ namespace System.Data.SqlClient
 
                #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
@@ -119,6 +140,10 @@ namespace System.Data.SqlClient
 
                #region Methods
 
+               public XmlReader ExecuteXmlReader() {
+                       return SqlXmlTextReader.Create(ExecuteReader(CommandBehavior.SequentialAccess));
+               }
+
                public new SqlDataReader ExecuteReader()\r
                {\r
                        return (SqlDataReader)ExecuteReader(CommandBehavior.Default);\r
@@ -148,7 +173,7 @@ namespace System.Data.SqlClient
 \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
@@ -190,4 +215,4 @@ namespace System.Data.SqlClient
 
                #endregion // Methods\r
        }
-}
\ No newline at end of file
+}