* Tds.cs (ProcessLoginAck): Set TdsVersion to the version
authorVeerapuram Varadhan <v.varadhan@gmail.com>
Thu, 26 Feb 2009 04:18:02 +0000 (04:18 -0000)
committerVeerapuram Varadhan <v.varadhan@gmail.com>
Thu, 26 Feb 2009 04:18:02 +0000 (04:18 -0000)
        supported by the server.
        (GetColumnValue): lcid and sortId are available only from Tds 8.

        * Tds80.cs (ProcessColumnInfo, ProcessOutputParam): Call base
        methods if the server version is less than Tds 8.

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

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

index 85a07c6e5890c94b8e78c4391afee224400b4524..037fe48279698ed352ad4f6d78bd038c964d62c7 100644 (file)
@@ -1,3 +1,12 @@
+2009-02-26  Veerapuram Varadhan  <vvaradhan@novell.com>
+
+       * Tds.cs (ProcessLoginAck): Set TdsVersion to the version
+       supported by the server.
+       (GetColumnValue): lcid and sortId are available only from Tds 8.
+
+       * Tds80.cs (ProcessColumnInfo, ProcessOutputParam): Call base
+       methods if the server version is less than Tds 8.
+       
 2009-02-19  Veerapuram Varadhan  <vvaradhan@novell.com>
 
        * Tds.cs: Tds 8 collation support
index 1a2fb5efe8533112f362355fb890373a8b00143d..94cf613aa368d7a6c1039ebd04d29695e73f4411 100644 (file)
@@ -726,7 +726,7 @@ namespace Mono.Data.Tds.Protocol
                        if (colType == null)
                                throw new ArgumentNullException ("colType");
 #endif
-                       if (ordinal > -1) {
+                       if (ordinal > -1 && tdsVersion > TdsVersion.tds70) {
 #if NET_2_0
                                lcid = (int) columns[ordinal].LCID;
                                sortId = (int) columns[ordinal].SortOrder; 
@@ -1224,12 +1224,11 @@ namespace Mono.Data.Tds.Protocol
                            (colType == TdsColumnType.BigChar || colType == TdsColumnType.BigNVarChar || 
                             colType == TdsColumnType.BigVarChar || colType == TdsColumnType.NChar ||
                                 colType == TdsColumnType.NVarChar)) {
-                                   // Read collation for SqlServer 2000 and beyond
-                                       byte[] collation;
-                                   collation = Comm.GetBytes (5, true);
-                                       enc = TdsCharset.GetEncoding (collation);
-                                       //comm.Skip (5);
-                                       shortLen = true;
+                               // Read collation for SqlServer 2000 and beyond
+                               byte[] collation;
+                               collation = Comm.GetBytes (5, true);
+                               enc = TdsCharset.GetEncoding (collation);
+                               shortLen = true;
                        } else {
                                shortLen = (tdsVersion >= TdsVersion.tds70) && (wideChars || !outputParam);
                        }
@@ -1598,24 +1597,38 @@ namespace Mono.Data.Tds.Protocol
 
                protected void ProcessLoginAck ()
                {
-                       //TODO: Reade the server version and process packets accordingly
+                       uint srvVersion = 0;
                        GetSubPacketLength ();
+                       
+                       // Valid only for a Login7 request
+                       if (tdsVersion >= TdsVersion.tds70) {
+                               comm.Skip (1);
+                               srvVersion = (uint)comm.GetTdsInt ();
 
+                               switch (srvVersion) {
+                               case 0x07000000: 
+                                       tdsVersion = TdsVersion.tds70;
+                                       break;
+                               case 0x07010000:
+                                       tdsVersion = TdsVersion.tds80;
+                                       break;
+                               case 0x71000001:
+                                       tdsVersion = TdsVersion.tds81;
+                                       break;
+                               case 0x72090002:
+                                       tdsVersion = TdsVersion.tds90;
+                                       break;
+                               }
+                       }
+                       
                        if (tdsVersion >= TdsVersion.tds70) {
-                               comm.Skip (5);
                                int nameLength = comm.GetByte ();
                                databaseProductName = comm.GetString (nameLength);
                                databaseMajorVersion = comm.GetByte ();
                                databaseProductVersion = String.Format ("{0}.{1}.{2}", databaseMajorVersion.ToString("00"),
                                                                comm.GetByte ().ToString("00"), 
                                                                (256 * comm.GetByte () + comm.GetByte ()).ToString("0000"));
-                               // VARADHAN: TDS 8 Debugging
-                               /*
-                               Console.WriteLine ("tdsVersion >= tds70");
-                               Console.WriteLine ("\t Name: {0}, version: {1}", databaseProductName, databaseProductVersion);
-                               */
-                       }
-                       else {
+                       } else {
                                comm.Skip (5);
                                short nameLength = comm.GetByte ();
                                databaseProductName = comm.GetString (nameLength);
index 6f3fbe3c61d11fa0285a60210dbac47ce09753ab..5f3e3b2badafc9e58786ebc455aab5e391b5f9b0 100644 (file)
@@ -71,6 +71,10 @@ namespace Mono.Data.Tds.Protocol {
 
                protected override TdsDataColumnCollection ProcessColumnInfo ()
                {
+                       // We are connected to a Sql 7.0 server
+                       if (TdsVersion < TdsVersion.tds80)
+                               return base.ProcessColumnInfo ();
+                       
                        // VARADHAN: TDS 8 Debugging
                        //Console.WriteLine ("Tds80.cs: In ProcessColumnInfo... entry");
                        TdsDataColumnCollection result = new TdsDataColumnCollection ();
@@ -186,6 +190,10 @@ namespace Mono.Data.Tds.Protocol {
 
                protected override void ProcessOutputParam ()
                {
+                       // We are connected to a Sql 7.0 server
+                       if (TdsVersion < TdsVersion.tds80)
+                               base.ProcessOutputParam ();
+
                        GetSubPacketLength ();
                        
                        Comm.Skip ((Comm.GetByte () & 0xff) <<1); // Parameter name