472,102 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Difference between .NET 1.1 Dataset.ReadXML and .NET2.0 BETA Dataset.ReadXML

I have written a web service in C#, .NET 1.1 which reads a XML file into a
dataset.
This is just a plain XML file. First I use the Dataset.ReadXmlScheme
function and pass the XML file to it. Then I convert data type of one of the
column to integer and then I use the Dataset.ReadXml function and pass the
same file to it. This works on my machine, but when I run it on a .NET 2.0
machine it thows an exception with message "Input string was not in correct
format". The XML document is well formed and also all the column has all
values numeric.
So I installed .NET 2.0 on my machine keeping .NET 1.1 as it was. Then on
asociating the web service virtual directory in IIS with .NET 1.1 it works
fine and on associating it with .NET 2.0 it gives above error.
Does it has to do with converting the column to integer type?
Nov 12 '05 #1
8 5612
Can you give me the XML which causes this, as well as the call stack where
the Exception is thrown?

Thanks,
Zafar

"Nikhilesh Mehendale" <ni********@maqsoftware.com> wrote in message
news:ec*************@TK2MSFTNGP12.phx.gbl...
I have written a web service in C#, .NET 1.1 which reads a XML file into a
dataset.
This is just a plain XML file. First I use the Dataset.ReadXmlScheme
function and pass the XML file to it. Then I convert data type of one of the column to integer and then I use the Dataset.ReadXml function and pass the
same file to it. This works on my machine, but when I run it on a .NET 2.0
machine it thows an exception with message "Input string was not in correct format". The XML document is well formed and also all the column has all
values numeric.
So I installed .NET 2.0 on my machine keeping .NET 1.1 as it was. Then on
asociating the web service virtual directory in IIS with .NET 1.1 it works
fine and on associating it with .NET 2.0 it gives above error.
Does it has to do with converting the column to integer type?

Nov 12 '05 #2
The attachement was blocked since it was an XML file, please send in some
other format like .zip.

Thanks,
Zafar

"Nikhilesh Mehendale" <ni********@maqsoftware.com> wrote in message
news:uo**************@TK2MSFTNGP10.phx.gbl...
The attached file (only part of it as the original file is large) contains
an attribute score for in every child element.
This after loading the schema into the dataset is converted to integer
format using ReadXmlSchema function of the DataSet class and then the XML
file is read using the ReadXml function. Suprisingly it works fine if I
associate it to run with .NET 1.1 and does not if I associate it with .NET
2.0 with out. Also I am not able to debug when I use .NET 2.0 using Visual
Studio 2003.
This is the call stack
[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options,
NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2751235 System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo
info) +102
System.Xml.XmlConvert.ToInt32(String s) +100
System.Data.Common.Int32Storage.ConvertXmlToObject (String s) +23
System.Data.XmlDataLoader.LoadColumn(DataColumn column, Object[]
foundColumns) +350
System.Data.XmlDataLoader.LoadTopMostTable(DataTab le table) +592
System.Data.XmlDataLoader.LoadData(XmlReader reader) +1669565
System.Data.DataSet.ReadXml(XmlReader reader, Boolean denyResolving) +842 System.Data.DataSet.ReadXml(String fileName) +62
MBADatabase.MBAData.GetScores() +138
MBADatabase.ScoreSheet.Page_Load(Object sender, EventArgs e) +78
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

Nov 12 '05 #3
Thanks. Could you also post the code which works in .NET 1.1 and not in .NET
2.0.?

Zafar Abbas
"Nikhilesh Mehendale" <ni********@maqsoftware.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
File attached, compressed using Winzip 9.0

Nov 12 '05 #4
could you please provide the source code as well?

"Nikhilesh Mehendale" <ni********@maqsoftware.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
File attached, compressed using Winzip 9.0

Nov 12 '05 #5
DataSet dataSet = new DataSet();
string xmlFile = "C:\Data.xml";

//Check if the file exists
if (File.Exists(xmlFile))
{
dataSet.ReadXmlSchema(xmlFile);
}
else //return null if file does not exist
{
return null;
}

//Convert the scores column to integer
dataSet.Tables[0].Columns["score"].DataType = typeof(int);

try
{
dataSet.ReadXml(xmlFile);
}
catch(Exception ea)
{
MessageBox.Show(ea.Message);
}

This is the part of code wich works in .Net Framework 1.1 and not in 2.0.
The try block throws exception at the statement dataSet.ReadXml(xmlFile)
Nov 12 '05 #6
Nikhilesh ,
I am realy sorry, I need you to send me the XML file again. I am unable to
locate it in the archive.

Thanks,
Zafar
"Nikhilesh Mehendale" <ni********@maqsoftware.com> wrote in message
news:O0**************@TK2MSFTNGP14.phx.gbl...
DataSet dataSet = new DataSet();
string xmlFile = "C:\Data.xml";

//Check if the file exists
if (File.Exists(xmlFile))
{
dataSet.ReadXmlSchema(xmlFile);
}
else //return null if file does not exist
{
return null;
}

//Convert the scores column to integer
dataSet.Tables[0].Columns["score"].DataType = typeof(int);

try
{
dataSet.ReadXml(xmlFile);
}
catch(Exception ea)
{
MessageBox.Show(ea.Message);
}

This is the part of code wich works in .Net Framework 1.1 and not in 2.0.
The try block throws exception at the statement dataSet.ReadXml(xmlFile)

Nov 12 '05 #7
Nikhilesh,
This is an issue in .NET framework 2.0 which might be fixed in a service
pack. As a work around for .NET 2.0, could you rename your attribute score,
so that its name is different than the element itself.

Thanks,
Zafar
"Nikhilesh Mehendale" <ni********@maqsoftware.com> wrote in message
news:Ot**************@TK2MSFTNGP12.phx.gbl...
Here is the file
"Zafar Abbas" <so*****@somewhere.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Nikhilesh ,
I am realy sorry, I need you to send me the XML file again. I am unable to locate it in the archive.

Thanks,
Zafar
"Nikhilesh Mehendale" <ni********@maqsoftware.com> wrote in message
news:O0**************@TK2MSFTNGP14.phx.gbl...
DataSet dataSet = new DataSet();
string xmlFile = "C:\Data.xml";

//Check if the file exists
if (File.Exists(xmlFile))
{
dataSet.ReadXmlSchema(xmlFile);
}
else //return null if file does not exist
{
return null;
}

//Convert the scores column to integer
dataSet.Tables[0].Columns["score"].DataType = typeof(int);

try
{
dataSet.ReadXml(xmlFile);
}
catch(Exception ea)
{
MessageBox.Show(ea.Message);
}

This is the part of code wich works in .Net Framework 1.1 and not in 2.0. The try block throws exception at the statement dataSet.ReadXml(xmlFile)



Nov 12 '05 #8
Well, may be that also. But also the name of the root element and the name
of the child element is same that was causing problem. I changes the name of
the root element from <score> to <scores> and it worked. May be .Net 2.0 is
strict about the names of root element and child elements

"Zafar Abbas" <so*****@somewhere.com> wrote in message
news:uK**************@TK2MSFTNGP12.phx.gbl...
Nikhilesh,
This is an issue in .NET framework 2.0 which might be fixed in a service
pack. As a work around for .NET 2.0, could you rename your attribute
score,
so that its name is different than the element itself.

Thanks,
Zafar
"Nikhilesh Mehendale" <ni********@maqsoftware.com> wrote in message
news:Ot**************@TK2MSFTNGP12.phx.gbl...
Here is the file
"Zafar Abbas" <so*****@somewhere.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
> Nikhilesh ,
> I am realy sorry, I need you to send me the XML file again. I am unable to > locate it in the archive.
>
> Thanks,
> Zafar
>
>
> "Nikhilesh Mehendale" <ni********@maqsoftware.com> wrote in message
> news:O0**************@TK2MSFTNGP14.phx.gbl...
>> DataSet dataSet = new DataSet();
>> string xmlFile = "C:\Data.xml";
>>
>> //Check if the file exists
>> if (File.Exists(xmlFile))
>> {
>> dataSet.ReadXmlSchema(xmlFile);
>> }
>> else //return null if file does not exist
>> {
>> return null;
>> }
>>
>> //Convert the scores column to integer
>> dataSet.Tables[0].Columns["score"].DataType = typeof(int);
>>
>> try
>> {
>> dataSet.ReadXml(xmlFile);
>> }
>> catch(Exception ea)
>> {
>> MessageBox.Show(ea.Message);
>> }
>>
>> This is the part of code wich works in .Net Framework 1.1 and not in 2.0. >> The try block throws exception at the statement dataSet.ReadXml(xmlFile) >>
>>
>
>



Nov 12 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Jeffrey A. Voigt | last post: by
1 post views Thread by mr_dom_is | last post: by
1 post views Thread by kids_pro | last post: by
1 post views Thread by Raymond Du | last post: by
4 posts views Thread by Shapper | last post: by
22 posts views Thread by Arne | last post: by
12 posts views Thread by Marc | last post: by
reply views Thread by leo001 | last post: by

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.