I have two queries:
Q1: select name from presidents where country = 'USA'
Q2: select 'Obama' as name from presidents where country = 'USA'
When using System.Data.Odbc.OdbcCommandExecuteReader
then the returned DbDataReader
contains 'Obama'
in case of Q1 and 'Obama '
in case of Q2.
Why is the string padded with trailing spaces in case of Q2 and what is the remedy?
Trimming is ugly and even wrong in some cases. I am using .Net Framework 3.5.
Here is the test code
OdbcCommand cmd = new OdbcCommand();
cmd.Connection = (OdbcConnection)DatabaseContext.Connection;
cmd.CommandText = "select 'Obama' from dual";
cmd.CommandType = CommandType.Text;
OdbcDataReader r = cmd.ExecuteReader();
if (r.Read())
{
String s = r.GetString(0);
// s now contains "Obama "
// with trailing spaces
}