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. Visual Basic
  4. dynamic deserialization

dynamic deserialization

Scheduled Pinned Locked Moved Visual Basic
xmldatabasequestion
11 Posts 3 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.
  • E Offline
    E Offline
    Ebube
    wrote on last edited by
    #1

    i have a table with th schema productid int productname varchar productattribute xml where the productattribute is supply by user through form say (12seagate) how can i deserialize this on the fly so i can say product.productattribute.size =12

    D 1 Reply Last reply
    0
    • E Ebube

      i have a table with th schema productid int productname varchar productattribute xml where the productattribute is supply by user through form say (12seagate) how can i deserialize this on the fly so i can say product.productattribute.size =12

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Ebube wrote:

      how can i deserialize this on the fly so i can say product.productattribute.size =12

      This doesn't make sense to me. Are you asking how you can set the value of a property that doesn't exist at design time?? You can't, since, obviously, the size property doesn't exist. It must be defined in the class before you can use it. You can do something more like this:

      product.productattribute("size") = 12
      

      IF this is what you're really trying to do...

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008
      But no longer in 2009...

      E 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Ebube wrote:

        how can i deserialize this on the fly so i can say product.productattribute.size =12

        This doesn't make sense to me. Are you asking how you can set the value of a property that doesn't exist at design time?? You can't, since, obviously, the size property doesn't exist. It must be defined in the class before you can use it. You can do something more like this:

        product.productattribute("size") = 12
        

        IF this is what you're really trying to do...

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008
        But no longer in 2009...

        E Offline
        E Offline
        Ebube
        wrote on last edited by
        #3

        thanks Dave Kreskowiak actually am looking for a way to break up this attribute so that i can have a report that look like ram size 256 maker seagate price 50 note that this value exit in database but size and maker are nodes in the (xml productattribute column)

        D D 2 Replies Last reply
        0
        • E Ebube

          thanks Dave Kreskowiak actually am looking for a way to break up this attribute so that i can have a report that look like ram size 256 maker seagate price 50 note that this value exit in database but size and maker are nodes in the (xml productattribute column)

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          You're going to have to explain this from the start. What you're saying doesn't make any sense at all. Report?? What report?? Where is the data stored and how? What's with the syntx you want?? how do the two relate to each other??

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008
          But no longer in 2009...

          E 1 Reply Last reply
          0
          • E Ebube

            thanks Dave Kreskowiak actually am looking for a way to break up this attribute so that i can have a report that look like ram size 256 maker seagate price 50 note that this value exit in database but size and maker are nodes in the (xml productattribute column)

            D Offline
            D Offline
            David Skelly
            wrote on last edited by
            #5

            Your question still isn't very clear. Are you saying that productattribute is stored as XML, so for example:

            <productattribute>
            <maker>Seagate</maker>
            <size>256</size>
            <price>50</price>
            </productattribute>

            and you want to know how to break that XML up to get the sub-nodes for reporting. Is that the question?

            E 1 Reply Last reply
            0
            • D David Skelly

              Your question still isn't very clear. Are you saying that productattribute is stored as XML, so for example:

              <productattribute>
              <maker>Seagate</maker>
              <size>256</size>
              <price>50</price>
              </productattribute>

              and you want to know how to break that XML up to get the sub-nodes for reporting. Is that the question?

              E Offline
              E Offline
              Ebube
              wrote on last edited by
              #6

              yes David Skelly

              D 1 Reply Last reply
              0
              • E Ebube

                yes David Skelly

                D Offline
                D Offline
                David Skelly
                wrote on last edited by
                #7

                This may be of help to you: XML data type tips in SQL Server 2005[^] It contains an example of how to work with XML data types in VB.

                E 1 Reply Last reply
                0
                • D David Skelly

                  This may be of help to you: XML data type tips in SQL Server 2005[^] It contains an example of how to work with XML data types in VB.

                  E Offline
                  E Offline
                  Ebube
                  wrote on last edited by
                  #8

                  thanks a lot. i hv read it he say "Let's say our Products table might have ProductID, ProductName, ProductCategory and ProductAttributesXML. We would then use ProductCategory to decide what type of class we store in ProductAttributesXML. So for ProductCategory='Digital Cameras" we could define a class DigitalCameraAttributes with fields such as Pixels, MaximumZoom, StorageType, and a special user control to show these details. Likewise, a class called HardDiskAttributes for the Hard Disks category." now i want to allow user to specifies this fields from form. so how can i define the class base on their input thanks

                  1 Reply Last reply
                  0
                  • D Dave Kreskowiak

                    You're going to have to explain this from the start. What you're saying doesn't make any sense at all. Report?? What report?? Where is the data stored and how? What's with the syntx you want?? how do the two relate to each other??

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                         2006, 2007, 2008
                    But no longer in 2009...

                    E Offline
                    E Offline
                    Ebube
                    wrote on last edited by
                    #9

                    thanks a lot dave. i hv read it he say "Let's say our Products table might have ProductID, ProductName, ProductCategory and ProductAttributesXML. We would then use ProductCategory to decide what type of class we store in ProductAttributesXML. So for ProductCategory='Digital Cameras" we could define a class DigitalCameraAttributes with fields such as Pixels, MaximumZoom, StorageType, and a special user control to show these details. Likewise, a class called HardDiskAttributes for the Hard Disks category." now i want to allow user to specifies this fields from form cos i do not know at design time the product fields. so how can i define the class base on their input. i hope it make sense.

                    D 1 Reply Last reply
                    0
                    • E Ebube

                      thanks a lot dave. i hv read it he say "Let's say our Products table might have ProductID, ProductName, ProductCategory and ProductAttributesXML. We would then use ProductCategory to decide what type of class we store in ProductAttributesXML. So for ProductCategory='Digital Cameras" we could define a class DigitalCameraAttributes with fields such as Pixels, MaximumZoom, StorageType, and a special user control to show these details. Likewise, a class called HardDiskAttributes for the Hard Disks category." now i want to allow user to specifies this fields from form cos i do not know at design time the product fields. so how can i define the class base on their input. i hope it make sense.

                      D Offline
                      D Offline
                      Dave Kreskowiak
                      wrote on last edited by
                      #10

                      Yikes. The only way this would be possible is if you generated code, compiled it and emitted an assembly for it at runtime. This is a VERY ADVANCED level topic and not something I've done, so I don't have any examples. For something like this, normally I'd use something like a "property bag" setup, where basic definitions for various fields common to all class types are defined in a custom collection. That collection would also use a seperately defined "property bag" kind of setup where you're storing key/value type/value information in a seperate collection. You'd also need custom serializer/deserializers to store/parse the data in/from XML files. If you really want the custom generated class route, Google for ".net dynamic class creation".

                      A guide to posting questions on CodeProject[^]
                      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                           2006, 2007, 2008
                      But no longer in 2009...

                      E 1 Reply Last reply
                      0
                      • D Dave Kreskowiak

                        Yikes. The only way this would be possible is if you generated code, compiled it and emitted an assembly for it at runtime. This is a VERY ADVANCED level topic and not something I've done, so I don't have any examples. For something like this, normally I'd use something like a "property bag" setup, where basic definitions for various fields common to all class types are defined in a custom collection. That collection would also use a seperately defined "property bag" kind of setup where you're storing key/value type/value information in a seperate collection. You'd also need custom serializer/deserializers to store/parse the data in/from XML files. If you really want the custom generated class route, Google for ".net dynamic class creation".

                        A guide to posting questions on CodeProject[^]
                        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                             2006, 2007, 2008
                        But no longer in 2009...

                        E Offline
                        E Offline
                        Ebube
                        wrote on last edited by
                        #11

                        thanks Dave am already storing key/value type/value information in the xml column in the database. i dont no much about custom serializer/deserializers. but the fact is that i only need to break this during report. i dont know if crytal report hav this ability to pull key/value type/value information from sql server

                        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