How to store HTML code in SQL server table

Discussion in 'ASP .Net' started by Peter Afonin, Nov 28, 2004.

  1. Peter Afonin

    Peter Afonin Guest

    Hello,

    I'm creating something like a web site builder in ASP.Net, and I need to
    store an HTML code in the SQL server table. If my customer just enters an
    HTML code, it is stored in the SQL server table like this: <table
    cellSpacing="0" cellPadding="0" width="760"
    border=&quot;0&quot;&gt;, instead of <table cellSpacing="0" cellPadding="0"
    width="760" border="0">

    This significantly increases the size of the stored code.

    Are there any conversion functions or something like this to avoid it? Where
    this conversion should be done - in ASP.Net or SQL server? How do I convert
    it back to create an HTML page?

    Please note that I must use the Unicode data type - ntext, nchar etc, since
    I'm using some Cyrillic characters.

    I would appreciate your advice very much.

    Thank you,

    --
    Peter Afonin
     
    Peter Afonin, Nov 28, 2004
    #1
    1. Advertising

  2. Peter,
    ntext in SQL Server will store Html markup just fine. You are encoding
    your html before storing it in the database. Find out where you are
    encoding the markup and change that code. Debug your code and make sure
    that you are indeed sending pure html to the database. SQL Server will not
    automatically encode html, so your code is doing it somewhere.

    Best regards,
    Jeffrey Palermo

    "Peter Afonin" <> wrote in message
    news:...
    > Hello,
    >
    > I'm creating something like a web site builder in ASP.Net, and I need to
    > store an HTML code in the SQL server table. If my customer just enters an
    > HTML code, it is stored in the SQL server table like this: &lt;table
    > cellSpacing=&quot;0&quot; cellPadding=&quot;0&quot; width=&quot;760&quot;
    > border=&quot;0&quot;&gt;, instead of <table cellSpacing="0"

    cellPadding="0"
    > width="760" border="0">
    >
    > This significantly increases the size of the stored code.
    >
    > Are there any conversion functions or something like this to avoid it?

    Where
    > this conversion should be done - in ASP.Net or SQL server? How do I

    convert
    > it back to create an HTML page?
    >
    > Please note that I must use the Unicode data type - ntext, nchar etc,

    since
    > I'm using some Cyrillic characters.
    >
    > I would appreciate your advice very much.
    >
    > Thank you,
    >
    > --
    > Peter Afonin
    >
    >
     
    Jeffrey Palermo [MCP], Nov 29, 2004
    #2
    1. Advertising

  3. Peter Afonin

    Henri Guest

    What is the code you use to store the string you get in the SQL database?

    "Peter Afonin" <> a écrit dans le message de
    news:...
    > Hello,
    >
    > I'm creating something like a web site builder in ASP.Net, and I need to
    > store an HTML code in the SQL server table. If my customer just enters an
    > HTML code, it is stored in the SQL server table like this: &lt;table
    > cellSpacing=&quot;0&quot; cellPadding=&quot;0&quot; width=&quot;760&quot;
    > border=&quot;0&quot;&gt;, instead of <table cellSpacing="0"

    cellPadding="0"
    > width="760" border="0">
    >
    > This significantly increases the size of the stored code.
    >
    > Are there any conversion functions or something like this to avoid it?

    Where
    > this conversion should be done - in ASP.Net or SQL server? How do I

    convert
    > it back to create an HTML page?
    >
    > Please note that I must use the Unicode data type - ntext, nchar etc,

    since
    > I'm using some Cyrillic characters.
    >
    > I would appreciate your advice very much.
    >
    > Thank you,
    >
    > --
    > Peter Afonin
    >
    >
    >
     
    Henri, Nov 29, 2004
    #3
  4. Peter Afonin

    Wayne Snyder Guest

    As the other poster states, it is not SQL that is doing the encoding, it is
    something else...

    Also, if the html pages will be less than 4000 unicode characters, you may
    prefer to strore the data in a varchar column.

    --
    Wayne Snyder, MCDBA, SQL Server MVP
    Mariner, Charlotte, NC
    www.mariner-usa.com
    (Please respond only to the newsgroups.)

    I support the Professional Association of SQL Server (PASS) and it's
    community of SQL Server professionals.
    www.sqlpass.org

    "Peter Afonin" <> wrote in message
    news:...
    > Hello,
    >
    > I'm creating something like a web site builder in ASP.Net, and I need to
    > store an HTML code in the SQL server table. If my customer just enters an
    > HTML code, it is stored in the SQL server table like this: &lt;table
    > cellSpacing=&quot;0&quot; cellPadding=&quot;0&quot; width=&quot;760&quot;
    > border=&quot;0&quot;&gt;, instead of <table cellSpacing="0"

    cellPadding="0"
    > width="760" border="0">
    >
    > This significantly increases the size of the stored code.
    >
    > Are there any conversion functions or something like this to avoid it?

    Where
    > this conversion should be done - in ASP.Net or SQL server? How do I

    convert
    > it back to create an HTML page?
    >
    > Please note that I must use the Unicode data type - ntext, nchar etc,

    since
    > I'm using some Cyrillic characters.
    >
    > I would appreciate your advice very much.
    >
    > Thank you,
    >
    > --
    > Peter Afonin
    >
    >
     
    Wayne Snyder, Nov 29, 2004
    #4
  5. Peter Afonin

    Peter Afonin Guest

    Thank you everyone for your suggestions.

    So far when I use ntext it works OK, then I use the Literal control and
    Server.Decode to write the data in ASP.Net.

    Peter

    "Wayne Snyder" <> wrote in message
    news:eL$...
    > As the other poster states, it is not SQL that is doing the encoding, it

    is
    > something else...
    >
    > Also, if the html pages will be less than 4000 unicode characters, you may
    > prefer to strore the data in a varchar column.
    >
    > --
    > Wayne Snyder, MCDBA, SQL Server MVP
    > Mariner, Charlotte, NC
    > www.mariner-usa.com
    > (Please respond only to the newsgroups.)
    >
    > I support the Professional Association of SQL Server (PASS) and it's
    > community of SQL Server professionals.
    > www.sqlpass.org
    >
    > "Peter Afonin" <> wrote in message
    > news:...
    > > Hello,
    > >
    > > I'm creating something like a web site builder in ASP.Net, and I need to
    > > store an HTML code in the SQL server table. If my customer just enters

    an
    > > HTML code, it is stored in the SQL server table like this: &lt;table
    > > cellSpacing=&quot;0&quot; cellPadding=&quot;0&quot;

    width=&quot;760&quot;
    > > border=&quot;0&quot;&gt;, instead of <table cellSpacing="0"

    > cellPadding="0"
    > > width="760" border="0">
    > >
    > > This significantly increases the size of the stored code.
    > >
    > > Are there any conversion functions or something like this to avoid it?

    > Where
    > > this conversion should be done - in ASP.Net or SQL server? How do I

    > convert
    > > it back to create an HTML page?
    > >
    > > Please note that I must use the Unicode data type - ntext, nchar etc,

    > since
    > > I'm using some Cyrillic characters.
    > >
    > > I would appreciate your advice very much.
    > >
    > > Thank you,
    > >
    > > --
    > > Peter Afonin
    > >
    > >

    >
    >
     
    Peter Afonin, Nov 29, 2004
    #5
  6. Wayne,
    Maybe it's just a typo, but varchar cannot be properly used with unicode
    and has a maximum length of 8000 characters. nvarchar has a limit of 4000
    characters and should be used for all applications for maintenance purposes
    (since most applications will have to support unicode in the future).


    --
    Best regards,
    Jeffrey Palermo
    Blog: http://dotnetjunkies.com/weblog/jpalermo

    "Wayne Snyder" <> wrote in message
    news:eL$...
    > As the other poster states, it is not SQL that is doing the encoding, it

    is
    > something else...
    >
    > Also, if the html pages will be less than 4000 unicode characters, you may
    > prefer to strore the data in a varchar column.
    >
    > --
    > Wayne Snyder, MCDBA, SQL Server MVP
    > Mariner, Charlotte, NC
    > www.mariner-usa.com
    > (Please respond only to the newsgroups.)
    >
    > I support the Professional Association of SQL Server (PASS) and it's
    > community of SQL Server professionals.
    > www.sqlpass.org
    >
    > "Peter Afonin" <> wrote in message
    > news:...
    > > Hello,
    > >
    > > I'm creating something like a web site builder in ASP.Net, and I need to
    > > store an HTML code in the SQL server table. If my customer just enters

    an
    > > HTML code, it is stored in the SQL server table like this: &lt;table
    > > cellSpacing=&quot;0&quot; cellPadding=&quot;0&quot;

    width=&quot;760&quot;
    > > border=&quot;0&quot;&gt;, instead of <table cellSpacing="0"

    > cellPadding="0"
    > > width="760" border="0">
    > >
    > > This significantly increases the size of the stored code.
    > >
    > > Are there any conversion functions or something like this to avoid it?

    > Where
    > > this conversion should be done - in ASP.Net or SQL server? How do I

    > convert
    > > it back to create an HTML page?
    > >
    > > Please note that I must use the Unicode data type - ntext, nchar etc,

    > since
    > > I'm using some Cyrillic characters.
    > >
    > > I would appreciate your advice very much.
    > >
    > > Thank you,
    > >
    > > --
    > > Peter Afonin
    > >
    > >

    >
    >
     
    Jeffrey Palermo [MCP], Nov 30, 2004
    #6
  7. Peter, I'm glad you have it working now.

    --
    Best regards,
    Jeffrey Palermo
    Blog: http://dotnetjunkies.com/weblog/jpalermo


    "Peter Afonin" <> wrote in message
    news:...
    > Thank you everyone for your suggestions.
    >
    > So far when I use ntext it works OK, then I use the Literal control and
    > Server.Decode to write the data in ASP.Net.
    >
    > Peter
    >
    > "Wayne Snyder" <> wrote in message
    > news:eL$...
    > > As the other poster states, it is not SQL that is doing the encoding, it

    > is
    > > something else...
    > >
    > > Also, if the html pages will be less than 4000 unicode characters, you

    may
    > > prefer to strore the data in a varchar column.
    > >
    > > --
    > > Wayne Snyder, MCDBA, SQL Server MVP
    > > Mariner, Charlotte, NC
    > > www.mariner-usa.com
    > > (Please respond only to the newsgroups.)
    > >
    > > I support the Professional Association of SQL Server (PASS) and it's
    > > community of SQL Server professionals.
    > > www.sqlpass.org
    > >
    > > "Peter Afonin" <> wrote in message
    > > news:...
    > > > Hello,
    > > >
    > > > I'm creating something like a web site builder in ASP.Net, and I need

    to
    > > > store an HTML code in the SQL server table. If my customer just enters

    > an
    > > > HTML code, it is stored in the SQL server table like this: &lt;table
    > > > cellSpacing=&quot;0&quot; cellPadding=&quot;0&quot;

    > width=&quot;760&quot;
    > > > border=&quot;0&quot;&gt;, instead of <table cellSpacing="0"

    > > cellPadding="0"
    > > > width="760" border="0">
    > > >
    > > > This significantly increases the size of the stored code.
    > > >
    > > > Are there any conversion functions or something like this to avoid it?

    > > Where
    > > > this conversion should be done - in ASP.Net or SQL server? How do I

    > > convert
    > > > it back to create an HTML page?
    > > >
    > > > Please note that I must use the Unicode data type - ntext, nchar etc,

    > > since
    > > > I'm using some Cyrillic characters.
    > > >
    > > > I would appreciate your advice very much.
    > > >
    > > > Thank you,
    > > >
    > > > --
    > > > Peter Afonin
    > > >
    > > >

    > >
    > >

    >
    >
     
    Jeffrey Palermo [MCP], Dec 5, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UnVkeQ==?=

    to store or not to store an image

    =?Utf-8?B?UnVkeQ==?=, Mar 29, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    675
    =?Utf-8?B?UnVkeQ==?=
    Mar 30, 2005
  2. Daves
    Replies:
    1
    Views:
    410
  3. jack
    Replies:
    1
    Views:
    400
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
    Apr 18, 2007
  4. Andy B
    Replies:
    1
    Views:
    874
    Alexey Smirnov
    Aug 8, 2008
  5. Renie83
    Replies:
    1
    Views:
    323
    Ray at
    Jul 9, 2003
Loading...

Share This Page