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 datatype, column length info using SqlDataAdapter, XmlDataDocument classes in C#

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

Scheduled Pinned Locked Moved C#
csharpdatabasexmlquestion
3 Posts 2 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

    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

    -- modified at 12:25 Friday 5th May, 2006

    P 1 Reply Last reply
    0
    • P PrashantJ

      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

      -- modified at 12:25 Friday 5th May, 2006

      P Offline
      P Offline
      Paul Brower
      wrote on last edited by
      #2

      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.

      P 1 Reply Last reply
      0
      • P Paul Brower

        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.

        P Offline
        P Offline
        PrashantJ
        wrote on last edited by
        #3

        Okay, 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, -- modified at 16:24 Friday 5th May, 2006

        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