473,395 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

DataSet.Fill() When Column Value is Space

I am trying to populate DataSets with results from SQL queries.
Usually, to that end, the DataSet.Fill method works fine. If however
the table includes a character field populated with a space, the
DataSet throws an exception. I assume that the restriction is because
of the DataSet's use of XML. I tried setting the XMLDataDocument's
PreserveWhiteSpace property, but to no avail.

The error message I receive is:
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 spec_handling Column. Expected type is
Char.
There must be a simple way to handle spaces in DataSets. Has anyone
found it?

Thanks.

-Mike Gage
Nov 15 '05 #1
2 6610
I've never had problem with spaces in dataset.
Do you have generate the dataset from the dataadapter? Change the dataset
collum type to string or how suggested to byte.

"Mike Gage" <mg***@talx.com> schrieb im Newsbeitrag
news:42**************************@posting.google.c om...
I am trying to populate DataSets with results from SQL queries.
Usually, to that end, the DataSet.Fill method works fine. If however
the table includes a character field populated with a space, the
DataSet throws an exception. I assume that the restriction is because
of the DataSet's use of XML. I tried setting the XMLDataDocument's
PreserveWhiteSpace property, but to no avail.

The error message I receive is:
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 spec_handling Column. Expected type is
Char.
There must be a simple way to handle spaces in DataSets. Has anyone
found it?

Thanks.

-Mike Gage

Nov 15 '05 #2
Thanks for the reply.

I am running tests where I don't explicitly define the dataset, but
where it is defined based upon the query that is populating the dataset.
This almost always works just fine. The problem comes when there is a
CHAR(1) column populated with a space.

The applicable code where I populate the dataset is:

------------------------------------------------------public void
executeStatement( string statement )
{
checkConnection( statement );
try
{
IfxDataAdapter dataAdapter = new IfxDataAdapter( statement,
ifxConnection );
DataSet dataSet = new DataSet( "dataset" );
dataAdapter.Fill( dataSet );
resultsFileStream.Flush();
resultsFileStreamWriter.WriteLine( "\r\n\r\nResults from
executing statement: \"" + statement + "\"" );
resultsFileStreamWriter.Flush();
dataSet.WriteXml( resultsFileStream );
resultsFileStream.Flush();
}
catch( IfxException e )
{
Console.WriteLine( "Exception caught while attempting to
execute: \"" + statement + "\"" );
printIfxExceptionInfo( e );
}
catch( Exception e )
{
Console.WriteLine( "Exception caught while attempting to
execute: \"" + statement + "\"" );
Console.WriteLine( e.Message );
}
}
-------------------------------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Eric Petruzzelli | last post by:
If I fill my dataset and there is no data. The dataset is still created with zero rows (all columns are there). When I add my first row using the script below, it takes over 2 seconds to add??? If...
1
by: Luki | last post by:
Hello i'm stuck on a seemingly small problem. i'm trying get the default value of a column in a table on a MS SQL Server. i try to use sp_columns. eg sp_columns @table_name = 'addresses' in...
6
by: Omar | last post by:
When I try to databind my comboBox (specifically field "emplcode") to a filled dataset , the contents of the comboBox displays a bunch of "System.Data.DataRowView". I assume the amount of times...
4
by: Michael Jones | last post by:
Ok.......... I'm trying to fill a parameterized table onto a Dataset via a sqlDataAdapter. It works fine if I fill the Dataset with all the column fields. What I want to do though is to only fill...
3
by: Mojtaba Faridzad | last post by:
Hi, I am a newbie! I am wondering how DataSet keeps the data. I am using MySQL as database engine. when I use "Fill" method to set a table in DataSet, does C# retreive all data (base on Select...
6
by: Kiran | last post by:
Hi, I am using typed dataset for Employees Table and found a problem, can anyone tell me what's wrong Case 1: Employees Table: ID: int,Not Null,Idendity, Primary col Name:varchar(20),Not...
8
by: Dan Keeley | last post by:
Hi, I have a dataset which is used to populate my datagrid something like this: My question is, how do I add a caluclated display column to the datagrid? It will be based on ScoreCardScore... ...
10
by: dauphian | last post by:
Hello, I am new to .net and am trying to build a report application that queries 4 different tables based on a id, and I need to return them in the same table for easy viewing. Basically, I...
0
JordanMartz
by: JordanMartz | last post by:
''' <summary> ''' Populates the DataGridView ''' </summary> Private Sub PopulateDataGridView() ' Set the column header names. userAccessGrid.ColumnCount = 5 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.