[Mono-dev] Extra space characters issue when using System.Data.DataTable.Select

Sorin Peste neaorin at gmail.com
Wed Oct 18 13:09:04 EDT 2006


Hello,
Here's a code snippet:

class Class1
{
	static void Main(string[] args)
	{
		System.Data.DataTable dataTable = new
System.Data.DataTable("Person");
		dataTable.Columns.Add("Name", typeof(string));

	
		dataTable.Rows.Add(new object[] {"Mike "}); // notice the
trailing space

		foreach (System.Data.DataRow row in dataTable.Select("Name =
'Mike'"))
			System.Console.WriteLine(row[0]);

	}
}

When running the above program, Mono outputs nothing, while MS .NET outputs
'Mike'. 

It seems the MS runtime's DataTable.Select ignores any trailing spaces when
evaluating expressions containing strings. Leading spaces are not ignored.
Personally, without looking at the spec, I think Mono has the correct idea,
but it's still a compatibility issue. When using fixed-length character
fields in database tables, any extra room is normally filled with spaces.

Sorin




More information about the Mono-devel-list mailing list