2008-12-05 Gonzalo Paniagua Javier <gonzalo@novell.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Fri, 5 Dec 2008 17:17:54 +0000 (17:17 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Fri, 5 Dec 2008 17:17:54 +0000 (17:17 -0000)
* Tds70.cs: support parameter names with or without a leading '@'.

svn path=/trunk/mcs/; revision=120854

mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/ChangeLog
mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs

index 7e2f448dc53756befa09240d39de893dd1624195..99fdd8a125da1251a6176acbb833bad6a571f393 100644 (file)
@@ -1,3 +1,8 @@
+
+2008-12-05 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * Tds70.cs: support parameter names with or without a leading '@'.
+
 2008-11-13  Veerapuram Varadhan  <vvaradhan@novell.com>
 
        * TdsComm.cs (ResetConnection, IsConnected): Added a property and
index fa7a48f53d712015ddbde2307dc24a3a8155af31..d0f163c163fb29db3c9704f9b4b1b7d9c46d1f3d 100644 (file)
@@ -83,14 +83,15 @@ namespace Mono.Data.Tds.Protocol
 
                        StringBuilder result = new StringBuilder ();
                        foreach (TdsMetaParameter p in Parameters) {
-                               string includeAt = "@";
-                               if (p.ParameterName [0] == '@')
-                                       includeAt = string.Empty;
+                               string parameterName = p.ParameterName;
+                               if (parameterName [0] == '@') {
+                                       parameterName = parameterName.Substring (1);
+                               }
                                if (p.Direction != TdsParameterDirection.ReturnValue) {
                                        if (result.Length > 0)
                                                result.Append (", ");
                                        if (p.Direction == TdsParameterDirection.InputOutput)
-                                               result.Append (String.Format("{0}{1}={1} output", includeAt, p.ParameterName));
+                                               result.AppendFormat ("@{0}={0} output", parameterName);
                                        else
                                                result.Append (FormatParameter (p));
                                }
@@ -396,8 +397,14 @@ namespace Mono.Data.Tds.Protocol
                                foreach (TdsMetaParameter param in parameters) {
                                        if (param.Direction == TdsParameterDirection.ReturnValue) 
                                                continue;
-                                       Comm.Append ( (byte) param.ParameterName.Length );
-                                       Comm.Append (param.ParameterName);
+                                       string pname = param.ParameterName;
+                                       if (pname != null && pname.Length > 0 && pname [0] == '@') {
+                                               Comm.Append ( (byte) pname.Length);
+                                               Comm.Append (pname);
+                                       } else {
+                                               Comm.Append ( (byte) (pname.Length + 1));
+                                               Comm.Append ("@" + pname);
+                                       }
                                        short status = 0; // unused
                                        if (param.Direction != TdsParameterDirection.Input)
                                                status |= 0x01; // output
@@ -525,11 +532,12 @@ namespace Mono.Data.Tds.Protocol
 
                private string FormatParameter (TdsMetaParameter parameter)
                {
-                       string includeAt = "@";
-                       if (parameter.ParameterName [0] == '@')
-                               includeAt = string.Empty;
+                       string parameterName = parameter.ParameterName;
+                       if (parameterName [0] == '@') {
+                               parameterName = parameterName.Substring (1);
+                       }
                        if (parameter.Direction == TdsParameterDirection.Output)
-                               return String.Format ("{0}{1}={1} output", includeAt, parameter.ParameterName);
+                               return String.Format ("@{0}={0} output", parameterName);
                        if (parameter.Value == null || parameter.Value == DBNull.Value)
                                return parameter.ParameterName + "=NULL";
 
@@ -586,7 +594,7 @@ namespace Mono.Data.Tds.Protocol
                                break;
                        }
 
-                       return includeAt + parameter.ParameterName + "=" + value;
+                       return "@" + parameterName + "=" + value;
                }
 
                public override string Prepare (string commandText, TdsMetaParameterCollection parameters)