Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
dt.ReadXml("C:\Users\shanky.gupta\Desktop\xsd\x.xsd", XmlReadMode.ReadSchema)
Posted
Comments
kashif Atiq 25-May-15 1:33am    
Can you show the schema of your xsd and name of that extra column that you are getting?
Member 10341477 25-May-15 2:27am    
<pre lang="xml"><xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="usr_0_Account_Summary">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:int" name="AccountNumber"/>
<xs:element type="xs:int" name="DisplayAcctNumber"/>
<xs:element type="xs:string" name="AccountType"/>
<xs:element type="xs:short" name="OpenningBalance"/>
<xs:element type="xs:byte" name="ClosingBalance"/>
<xs:element type="xs:int" name="StmtBarCode"/>
<xs:element type="xs:int" name="FromDate"/>
<xs:element type="xs:int" name="ToDate"/>
<xs:element type="xs:string" name="PDFPassword"/>
<xs:element name="usr_0_RETAIL_TRANS_DATA" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:byte" name="Id"/>
<xs:element type="xs:int" name="AccountNumber"/>
<xs:element type="xs:int" name="TransDate"/>
<xs:element type="xs:int" name="ValueDate"/>
<xs:element type="xs:short" name="TransCode"/>
<xs:element type="xs:string" name="Description"/>
<xs:element type="xs:string" name="NarrativeLine1"/>
<xs:element type="xs:short" name="TransactionAmount"/>
<xs:element type="xs:byte" name="Credit"/>
<xs:element type="xs:byte" name="Debit"/>
<xs:element type="xs:short" name="Balance"/>
<xs:element type="xs:short" name="OpeningBalance"/>
<xs:element type="xs:short" name="ClosingBalance"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema></pre>
Member 10341477 25-May-15 2:28am    
I am getting usr_0_Account_Summary_id as an extra column in my dataset . Please help me out

1 solution

this is auto generated column for maintaining unique ids

why not remove that column from your table right after reading schema values?


dt.ReadXml("C:\Users\shanky.gupta\Desktop\xsd\x.xsd", XmlReadMode.ReadSchema) 
dt.Columns.Remove("usr_0_Account_Summary_id")

OR if dt is a dataset then you can use

dt.Tables(0).Columns.Remove("usr_0_Account_Summary_id")
 
Share this answer
 
v2
Comments
Member 10341477 25-May-15 3:53am    
* Suppose incase your are importing multiple table from xsd file .
* And if your table already contains a field name usr_0_Account_Summary_id.
kashif Atiq 25-May-15 3:59am    
* if you have multiple tables in return than you have to give index of that table in dt.Tables(your integer table index here).Columns.Remove("usr_0_Account_Summary_id") from the table from which you want to delete column

* i never tried this but my guess is that in this case weather system will not create new column or it will creates another column with any other name most probably with "usr_0_Account_Summary_id_id"

if my answer solved your problem then please mark it as accepted
Member 10341477 25-May-15 4:17am    
Reply Modify the comment. Delete the comment.
And if xsd already contains usr_0_Account_Summary_id then another column name usr_0_Account_Summary_id_0 will be generated . Is there any generic solution is there.
Member 10341477 25-May-15 4:21am    
If we are importing multiple table and columns from a xsd file . Then , a extra column is getting added into the dataset .usr_0_Account_Summary_id

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900