Click here to Skip to main content
15,884,388 members
Home / Discussions / C#
   

C#

 
GeneralRe: STRING MANIPULATION Pin
leppie20-Jan-04 6:23
leppie20-Jan-04 6:23 
GeneralRe: STRING MANIPULATION Pin
Jose Fco Bonnin21-Jan-04 4:07
Jose Fco Bonnin21-Jan-04 4:07 
GeneralRe: STRING MANIPULATION Pin
leppie21-Jan-04 6:09
leppie21-Jan-04 6:09 
GeneralRe: STRING MANIPULATION Pin
POKRI21-Jan-04 2:09
POKRI21-Jan-04 2:09 
GeneralOWC components Pin
pankajdaga20-Jan-04 3:13
pankajdaga20-Jan-04 3:13 
GeneralDirectX CaptureBuffer run-time error Pin
Shimi12319-Jan-04 23:42
Shimi12319-Jan-04 23:42 
GeneralRe: DirectX CaptureBuffer run-time error Pin
Shimi12320-Jan-04 3:02
Shimi12320-Jan-04 3:02 
GeneralData type lost when convertingto XML Pin
Yaron K.19-Jan-04 23:23
Yaron K.19-Jan-04 23:23 
Hi

I am writing code which accepts an array of objects, converts them to XML and loads them into a dataset.
My problem is that when the XML is created, it does not contain an indication of the data types of the fields. As a result, all the data types of the columns in the dataset are System.String.
Is there a way to force creation of shcemea when creating the XML string?

Here is the code:

[Serializable]
[XmlType("MyClass")]

public class MyClass
{
[XmlAttribute("IntField")]
public int IntField;

[XmlAttribute("StringField")]
public string StringField;

[XmlAttribute("ByteField")]
public byte ByteField;

public MyClass() {}
}

string xmlString;
System.Xml.Serialization.XmlSerializer xmlSer;
XmlWriter xmlWriter;
MyClass myObj = new MyClass();
StringWriter sw = new StringWriter();

myObj.IntField = 1;
myObj.StringField = "a string...";
myObj.ByteField = 2;

xmlWriter = new XmlTextWriter(sw);
xmlSer = new XmlSerializer(typeof(MyClass));

xmlSer.Serialize(xmlWriter,myObj);
xmlString = sw.ToString();

// at this point the xmlString looks as follows:
//"
//<myclass xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" intfield="1" stringfield="a string..." bytefield="2">"


DataSet ds = new DataSet();
StringReader sr = new StringReader(xmlString);
ds.ReadXml(sr);

// At this point ds.Tables[0].Columns[0].DataType.ToString() returns System.String instead of System.32
GeneralRe: Data type lost when convertingto XML Pin
Heath Stewart20-Jan-04 4:05
protectorHeath Stewart20-Jan-04 4:05 
Generalcontrol in menu Pin
Mohamad Al Husseiny19-Jan-04 20:27
Mohamad Al Husseiny19-Jan-04 20:27 
GeneralInstaller startmenu question Pin
joepardue19-Jan-04 16:10
joepardue19-Jan-04 16:10 
GeneralRe: Installer startmenu question Pin
Shahin7719-Jan-04 17:46
Shahin7719-Jan-04 17:46 
GeneralRe: Installer startmenu question Pin
Heath Stewart19-Jan-04 20:23
protectorHeath Stewart19-Jan-04 20:23 
GeneralRe: Installer startmenu question Pin
joepardue20-Jan-04 4:23
joepardue20-Jan-04 4:23 
QuestionHow to get the target that *.lnk link to Pin
god4k19-Jan-04 16:07
god4k19-Jan-04 16:07 
GeneralImages, SQL and C# -PLEASE HELP Pin
Peter Greenall19-Jan-04 14:28
Peter Greenall19-Jan-04 14:28 
GeneralRe: Images, SQL and C# -PLEASE HELP Pin
Heath Stewart19-Jan-04 19:53
protectorHeath Stewart19-Jan-04 19:53 
GeneralRe: Images, SQL and C# -PLEASE HELP Pin
Peter Greenall20-Jan-04 1:05
Peter Greenall20-Jan-04 1:05 
GeneralRe: Images, SQL and C# -PLEASE HELP Pin
Jose Fco Bonnin20-Jan-04 5:41
Jose Fco Bonnin20-Jan-04 5:41 
General(?) about transfering to C# Pin
Snyp19-Jan-04 14:02
Snyp19-Jan-04 14:02 
GeneralRe: (?) about transfering to C# Pin
Heath Stewart19-Jan-04 19:41
protectorHeath Stewart19-Jan-04 19:41 
GeneralPerformance issues Pin
lpRomang19-Jan-04 10:54
lpRomang19-Jan-04 10:54 
GeneralRe: Performance issues Pin
leppie20-Jan-04 6:26
leppie20-Jan-04 6:26 
GeneralSharing Crystal Reports Documents between .Net and Delphi. Pin
Shahin7719-Jan-04 9:37
Shahin7719-Jan-04 9:37 
Generalmemory problems!! Pin
abc87619-Jan-04 9:30
abc87619-Jan-04 9:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.