Click here to Skip to main content
15,919,749 members
Home / Discussions / C#
   

C#

 
GeneralRe: Comparing two HTMLDocuments Pin
makuda8-May-06 23:45
makuda8-May-06 23:45 
Questiontooltip Pin
Manu_818-May-06 13:28
Manu_818-May-06 13:28 
AnswerRe: tooltip Pin
sathish s8-May-06 21:54
sathish s8-May-06 21:54 
Questioncontro with custom properties Pin
Susuko8-May-06 13:25
Susuko8-May-06 13:25 
AnswerRe: contro with custom properties Pin
DigitalKing8-May-06 17:18
DigitalKing8-May-06 17:18 
GeneralRe: contro with custom properties Pin
Sasuko9-May-06 5:07
Sasuko9-May-06 5:07 
QuestionC#, CompactFramework and RAS Pin
martin_hughes8-May-06 10:31
martin_hughes8-May-06 10:31 
QuestionDetermine max column length info using SqlDataAdapter, XmlDataDocument classes in C# Pin
PrashantJ8-May-06 10:18
PrashantJ8-May-06 10:18 
I had posted this question last friday, but havent found a solution yet, so posting it again in case somebody is aware of the solution.

** Original message **
Hello,

This is my code which will convert the ADO resultset to XML in C#.
I actually need the column type, column max length etc also in the xml, like the column type/length of id, loginuserid, deptid, wrkstnid etc.
So I am not sure whether I need to pass some parameters to SqlDataAdapter class while executing the SQL command or the XmlDataDocument class has some methods which would print out the datatype and column length information in the XML. Looked at both the classes, didnt find any method, anybody has any ideas about this? Thanks

DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds);

if (ds.Tables.Count>0)
{
_sBody = new StringBuilder("", _bodySize);
//Get xml representation of the dataset
XmlDataDocument srcXML = new XmlDataDocument(ds);
srcXML.Save("c:\\XMLDocument.xml");
....
}

<NewDataSet>
<Table>
<id>1</id>
<LoginUserId>tpmadmin</LoginUserId>
<DeptId>1</DeptId>
<WrkstnId>1</WrkstnId>
</Table>
<Table>
<id>2</id>
<LoginUserId>sysadmin</LoginUserId>
<DeptId>2</DeptId>
<WrkstnId>2</WrkstnId>
</Table>
</NewDataSet>

-----------------------------------------------
** Paul Brower's Reply **
Try this, (with 'ds' being your dataset)


ds.WriteXml(@"c:\thedataset.xml",System.Data.XmlWriteMode.WriteSchema) ;

That will write out all your xml with the schema.

-----------------------------------------------
** Question **
I actually want the max size of the column and I think that information is missing in the XML. The XML looks something like this. Max size of the column is used by the XSL to print the data. For datatypes like int, numeric, datetime I can manage the column lenght, problem arises only when its of type string, char etc
It has the column name, type, minOccurs. I think the max size of the column is missing, do I need to try some other method, or any other argument? Thanks,


<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="id" type="xs:int" minOccurs="0" />
<xs:element name="LoginUserId" type="xs:string" minOccurs="0" />



Thanks.



-- modified at 17:47 Monday 8th May, 2006
QuestionIs this a bad way to multithread? Pin
Joshua Lunsford8-May-06 10:13
Joshua Lunsford8-May-06 10:13 
AnswerRe: Is this a bad way to multithread? Pin
stbaker8-May-06 10:38
stbaker8-May-06 10:38 
GeneralRe: Is this a bad way to multithread? Pin
Robert Rohde8-May-06 10:49
Robert Rohde8-May-06 10:49 
AnswerRe: Is this a bad way to multithread? Pin
Robert Rohde8-May-06 10:46
Robert Rohde8-May-06 10:46 
AnswerRe: Is this a bad way to multithread? Pin
stbaker8-May-06 11:18
stbaker8-May-06 11:18 
AnswerRe: Is this a bad way to multithread? Pin
Andy Brummer8-May-06 12:34
sitebuilderAndy Brummer8-May-06 12:34 
QuestionThreads and functions... Pin
Shy Agam8-May-06 10:09
Shy Agam8-May-06 10:09 
AnswerRe: Threads and functions... Pin
Robert Rohde8-May-06 10:36
Robert Rohde8-May-06 10:36 
GeneralRe: Threads and functions... Pin
Shy Agam8-May-06 11:54
Shy Agam8-May-06 11:54 
Question"The Server is not operational" when authenticating user to active directory Pin
krishna nimmalapudi8-May-06 9:55
krishna nimmalapudi8-May-06 9:55 
QuestionCursor and windows form Pin
indimu8-May-06 9:39
indimu8-May-06 9:39 
AnswerRe: Cursor and windows form Pin
Shy Agam8-May-06 23:38
Shy Agam8-May-06 23:38 
QuestionListbox Pin
JMichael24688-May-06 9:37
JMichael24688-May-06 9:37 
AnswerRe: Listbox Pin
NaNg152418-May-06 9:51
NaNg152418-May-06 9:51 
AnswerRe: Listbox Pin
microsoc8-May-06 16:31
microsoc8-May-06 16:31 
GeneralRe: Listbox Pin
JMichael24689-May-06 2:44
JMichael24689-May-06 2:44 
QuestionFew focused questions Pin
NaNg152418-May-06 9:37
NaNg152418-May-06 9:37 

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.