[Mono-bugs] [Bug 36577][Nor] Changed - SqlDataReader.GetString() returns extra character.

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Fri, 17 Jan 2003 14:36:20 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by egonia@acxiom.com.

http://bugzilla.ximian.com/show_bug.cgi?id=36577

--- shadow/36577	Fri Jan 17 11:05:00 2003
+++ shadow/36577.tmp.25513	Fri Jan 17 14:36:20 2003
@@ -48,6 +48,71 @@
 Thanks in advance.
 
 ------- Additional Comments From danmorg@sc.rr.com  2003-01-17 11:04 -------
 Close bug.
 Bug was fixed by Tim Coleman on 12/22/2002 in cvs.
 Mono 0.18 release should include this fix.
+
+------- Additional Comments From egonia@acxiom.com  2003-01-17 14:36 -------
+Here is the test case using MSSQL 7.0, Microsoft .Net and CVS as of 
+this morning.
+
+using System;
+using System.Data.SqlClient;
+
+class TestGetString
+{
+	public static void Main()
+	{
+		SqlConnection dbconn = null;
+		SqlCommand command = null;
+		SqlDataReader reader = null;
+		
+		try
+		{
+			dbconn = new SqlConnection
+("Server=cwynms03.corp.acxiom.net;Initial Catalog=pubs;User 
+ID=datauser;Password=select!");
+			dbconn.Open();
+			
+			command = new SqlCommand("select au_lname 
+from authors", dbconn);
+			reader = command.ExecuteReader();
+			
+			while (reader.Read())
+			{
+				string au_lname = reader.GetString(0);
+				
+				Console.WriteLine("au_lname= -{0}-  
+Length is {1}", au_lname, au_lname.Length);
+				Console.WriteLine("Last character is 
+= \'{0}\' as int = {1}\n", au_lname[au_lname.Length-1], 
+Convert.ToInt32(au_lname[au_lname.Length-1]));
+			}
+		}
+		finally
+		{
+			reader.Close();
+			command.Dispose();
+			dbconn.Close();
+		}
+	}
+}
+
+Expected results produced from Microsoft .Net 1.0 SP2:
+C:\Projects\SNMPCollect>test.exe
+au_lname= -Bennet-  Length is 6
+Last character is = 't' as int = 116
+
+au_lname= -Blotchet-Halls-  Length is 14
+Last character is = 's' as int = 115
+
+etc...
+
+Results from CVS as of this morning on Redhat 7.3:
+[egonia@gonia snmpcollect]$ mono test.exe
+au_lname= -Bennet-  Length is 7
+Last character is = '' as int = 0
+
+au_lname= -Blotchet-Halls-  Length is 15
+Last character is = '' as int = 0
+etc...