Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Determine max column length info using SqlDataAdapter, XmlDataDocument classes in C#

Determine max column length info using SqlDataAdapter, XmlDataDocument classes in C#

Scheduled Pinned Locked Moved C#
xmldatabasequestioncsharphelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PrashantJ
    wrote on last edited by
    #1

    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"); .... } 1tpmadmin11

    2sysadmin22

    ----------------------------------------------- ** 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,

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups