In all my previous experience a space, ' ', was considered to be a
character, but I'm having trouble filling a dataset if a 'char' column
contains a space.

Example

cmd.CommandText = "create table spacetab(c1 char)";
cmd.ExecuteNonQuery();

cmd.CommandText = "insert into spacetab values (' ')";
cmd.ExecuteNonQuery();

[vendor]DataAdapter da = new
[vendor]DataAdapter("select * from spacetab", conn);
DataSet dataSet = new DataSet( "dataset" );
da.Fill( dataSet );

The error (with snippet of stack trace) that is returned is

System.ArgumentException: The DataSet Xml persistency does not support
the value '0x20' as Char value, please use Byte storage instead.
at System.Data.Common.CharStorage.Set(Int32 record, Object value)
at System.Data.DataColumn.set_Item(Int32 record, Object
value)Couldn't store
< > in c1 Column. Expected type is Char.


In other tests, this vendor's datareader is returning the column as a
Char; GetValue() returns a char and GetChar() works as well. This
seems to make sense since it is a char column and a .Net Framework
definition of char is any 2-byte value between 0 and 65535. So, why
would the Fill reject a Char with the value ' ' == 0x20?


Any information much appreciated.

-Chris

Re: DataSet Xml persistency does not support the value '0x20' as Char value by Kathleen

Kathleen
Thu Dec 18 19:19:55 CST 2003

Chris,

XML does funny things with whitespace. That's what the error is about. I
don't know of a workaround.

Kathleen

"Plausible Indirection" <cg22165@yahoo.com> wrote in message
news:7b9ebe1f.0312181430.2e9d38b5@posting.google.com...
> In all my previous experience a space, ' ', was considered to be a
> character, but I'm having trouble filling a dataset if a 'char' column
> contains a space.
>
> Example
>
> cmd.CommandText = "create table spacetab(c1 char)";
> cmd.ExecuteNonQuery();
>
> cmd.CommandText = "insert into spacetab values (' ')";
> cmd.ExecuteNonQuery();
>
> [vendor]DataAdapter da = new
> [vendor]DataAdapter("select * from spacetab", conn);
> DataSet dataSet = new DataSet( "dataset" );
> da.Fill( dataSet );
>
> The error (with snippet of stack trace) that is returned is
>
> System.ArgumentException: The DataSet Xml persistency does not support
> the value '0x20' as Char value, please use Byte storage instead.
> at System.Data.Common.CharStorage.Set(Int32 record, Object value)C
> at System.Data.DataColumn.set_Item(Int32 record, Object
> value)Couldn't store
> < > in c1 Column. Expected type is Char.
>
>
> In other tests, this vendor's datareader is returning the column as a
> Char; GetValue() returns a char and GetChar() works as well. This
> seems to make sense since it is a char column and a .Net Framework
> definition of char is any 2-byte value between 0 and 65535. So, why
> would the Fill reject a Char with the value ' ' == 0x20?
>
>
> Any information much appreciated.
>
> -Chris