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. String to code?

String to code?

Scheduled Pinned Locked Moved C#
helpquestion
5 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.
  • R Offline
    R Offline
    RoyRose78
    wrote on last edited by
    #1

    Hi all, Can I convert a string into code? For egs. if I have textbox with the text: "DataSet1.Tables[0].Rows[0][0].ToString()" I want to convert it to code.. I must say that I want to use objects that the application creates, so the object ICodeCompiler cannot help me.. Is there a way of doing it...??? Thanks RoyRose

    T 1 Reply Last reply
    0
    • R RoyRose78

      Hi all, Can I convert a string into code? For egs. if I have textbox with the text: "DataSet1.Tables[0].Rows[0][0].ToString()" I want to convert it to code.. I must say that I want to use objects that the application creates, so the object ICodeCompiler cannot help me.. Is there a way of doing it...??? Thanks RoyRose

      T Offline
      T Offline
      Tom Larsen
      wrote on last edited by
      #2

      What do you mean "I want to convert it to code"? If you want to dynamically create objects and methods in IL on the fly it is possible but far from a trivial task. I would also suggest that allowing your application to blindly execute instructions from any data source is a best a bad design pattern and at worst a huge security risk.

      M R 2 Replies Last reply
      0
      • T Tom Larsen

        What do you mean "I want to convert it to code"? If you want to dynamically create objects and methods in IL on the fly it is possible but far from a trivial task. I would also suggest that allowing your application to blindly execute instructions from any data source is a best a bad design pattern and at worst a huge security risk.

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #3

        unless he wants to include some sort of command interpreter in his application. but that would be another subject.


        Maximilien Lincourt Your Head A Splode - Strong Bad

        1 Reply Last reply
        0
        • T Tom Larsen

          What do you mean "I want to convert it to code"? If you want to dynamically create objects and methods in IL on the fly it is possible but far from a trivial task. I would also suggest that allowing your application to blindly execute instructions from any data source is a best a bad design pattern and at worst a huge security risk.

          R Offline
          R Offline
          RoyRose78
          wrote on last edited by
          #4

          Hey Tom, I'll tell you exactly what I mean. I want to have a control (like label) that the Text property is a code that refers to table field plus other manipulation, for example label.text = "Day(Orders.OrderDate)" will get the name of the day the customer bought a product... OR label.text = "Age(table["customer"].Row["BirthDate"])" Age is a function that gets a dateTime and returns the age... It's very similar to script code. I can manipulate only the current row. I won't be able to change the DB just to show it. I use other databinded labels, when I walk throught the rows, the label's data change & also the expression-labels suppose to change...

          T 1 Reply Last reply
          0
          • R RoyRose78

            Hey Tom, I'll tell you exactly what I mean. I want to have a control (like label) that the Text property is a code that refers to table field plus other manipulation, for example label.text = "Day(Orders.OrderDate)" will get the name of the day the customer bought a product... OR label.text = "Age(table["customer"].Row["BirthDate"])" Age is a function that gets a dateTime and returns the age... It's very similar to script code. I can manipulate only the current row. I won't be able to change the DB just to show it. I use other databinded labels, when I walk throught the rows, the label's data change & also the expression-labels suppose to change...

            T Offline
            T Offline
            Tom Larsen
            wrote on last edited by
            #5

            You know, I would almost recommend writing that kind of manipulation into the database itself instead of trying to pull it to the client to reinterpt. Or if you are doing more of a report kind of thing you might want to look into making the database return Xml so you can apply an Xslt. Or heck why not look into buying any number of the software advertised here to do this kind of thing.

            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