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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL Data Type for RTF

SQL Data Type for RTF

Scheduled Pinned Locked Moved Database
databasehtmlquestion
8 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.
  • G Offline
    G Offline
    gmhanna
    wrote on last edited by
    #1

    Hi, I'm trying to store RTF data inside of Transact-SQL and have used a data type of TEXT, however when retrieving the data from the database all I am receiving is the actual text, all of the RTF markup is gone and I am just receiving plain text. My question is what should I be using for a data type, since TEXT is not working the way I thought it would. Thank you, Glenn

    Glenn

    L 1 Reply Last reply
    0
    • G gmhanna

      Hi, I'm trying to store RTF data inside of Transact-SQL and have used a data type of TEXT, however when retrieving the data from the database all I am receiving is the actual text, all of the RTF markup is gone and I am just receiving plain text. My question is what should I be using for a data type, since TEXT is not working the way I thought it would. Thank you, Glenn

      Glenn

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      gmhanna wrote:

      what should I be using for a data type

      TEXT will do; it can also hold text with markup, like RTF and HTML. What property are you writing to the field? Make sure that you're saving the Rtf[^] property to the database, and not the Text[^]. The first will contain all text, with the Rtf-markup. The second property, "richTextBox1.Text", only contains plaintext.

      I are Troll :suss:

      G S 2 Replies Last reply
      0
      • L Lost User

        gmhanna wrote:

        what should I be using for a data type

        TEXT will do; it can also hold text with markup, like RTF and HTML. What property are you writing to the field? Make sure that you're saving the Rtf[^] property to the database, and not the Text[^]. The first will contain all text, with the Rtf-markup. The second property, "richTextBox1.Text", only contains plaintext.

        I are Troll :suss:

        G Offline
        G Offline
        gmhanna
        wrote on last edited by
        #3

        Hi Eddy, I have been trying to locate how this is attached. I am using a "Data Source" and the control is bound to the data source. I have been scouring the code trying to see something like rtftextbox.text or rtftextbox.rtf, but I'm not locating it. This control was placed on the form by dragging the RTF control from the data source and dropping it onto the form. I usually code the SQL stuff by hand but thought the automated tool was cool. Thank you,

        Glenn

        L 1 Reply Last reply
        0
        • G gmhanna

          Hi Eddy, I have been trying to locate how this is attached. I am using a "Data Source" and the control is bound to the data source. I have been scouring the code trying to see something like rtftextbox.text or rtftextbox.rtf, but I'm not locating it. This control was placed on the form by dragging the RTF control from the data source and dropping it onto the form. I usually code the SQL stuff by hand but thought the automated tool was cool. Thank you,

          Glenn

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          gmhanna wrote:

          I have been scouring the code trying to see something like rtftextbox.text or rtftextbox.rtf, but I'm not locating it.

          That's probably in InitializeComponent(), binding the property.

          gmhanna wrote:

          I usually code the SQL stuff by hand but thought the automated tool was cool.

          It can save a lot of boring typing-work, but you'll get surprises like these in return :)

          I are Troll :suss:

          G 1 Reply Last reply
          0
          • L Lost User

            gmhanna wrote:

            I have been scouring the code trying to see something like rtftextbox.text or rtftextbox.rtf, but I'm not locating it.

            That's probably in InitializeComponent(), binding the property.

            gmhanna wrote:

            I usually code the SQL stuff by hand but thought the automated tool was cool.

            It can save a lot of boring typing-work, but you'll get surprises like these in return :)

            I are Troll :suss:

            G Offline
            G Offline
            gmhanna
            wrote on last edited by
            #5

            I have this line of code in the InitializeComponent() for the binding. I could not find a definition for the word "Text", but I think what you are hinting at is I should try changing this to Rtf?

            this.commentsRichTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.reunionBindingSource, "Comments", true));

            Thank you,

            Glenn

            L 1 Reply Last reply
            0
            • G gmhanna

              I have this line of code in the InitializeComponent() for the binding. I could not find a definition for the word "Text", but I think what you are hinting at is I should try changing this to Rtf?

              this.commentsRichTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.reunionBindingSource, "Comments", true));

              Thank you,

              Glenn

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              That should work, but keep in mind that it's a generated file; I don't know whether the designer will pick up the changes correctly.

              I are Troll :suss:

              1 Reply Last reply
              0
              • L Lost User

                gmhanna wrote:

                what should I be using for a data type

                TEXT will do; it can also hold text with markup, like RTF and HTML. What property are you writing to the field? Make sure that you're saving the Rtf[^] property to the database, and not the Text[^]. The first will contain all text, with the Rtf-markup. The second property, "richTextBox1.Text", only contains plaintext.

                I are Troll :suss:

                S Offline
                S Offline
                Simon_Whale
                wrote on last edited by
                #7

                Just to be picky, if your using SQL 2005 or later i would use VARCHAR(MAX) As TEXT has been decpreciated and should be removed in the next version of SQL

                Marc Clifton wrote:

                That has nothing to do with VB. - Oh crap. I just defended VB!

                G 1 Reply Last reply
                0
                • S Simon_Whale

                  Just to be picky, if your using SQL 2005 or later i would use VARCHAR(MAX) As TEXT has been decpreciated and should be removed in the next version of SQL

                  Marc Clifton wrote:

                  That has nothing to do with VB. - Oh crap. I just defended VB!

                  G Offline
                  G Offline
                  gmhanna
                  wrote on last edited by
                  #8

                  Thank you for the information. I am currently using SQL Sever 2008 R2, so I'll change it.

                  Glenn

                  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