DataSet Xml persistency does not support the value '0x20' as Char value

  • Thread starter Plausible Indirection
  • Start date
P

Plausible Indirection

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
 
K

Kathleen Dollard

Chris,

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

Kathleen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top