473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to store HTML code in SQL server table

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
Nov 18 '05 #1
6 8962
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" <pv*@speakeasy.net> wrote in message
news:ey**************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #2
What is the code you use to store the string you get in the SQL database?

"Peter Afonin" <pv*@speakeasy.net> a écrit dans le message de
news:ey**************@TK2MSFTNGP11.phx.gbl...
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


Nov 18 '05 #3
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" <pv*@speakeasy.net> wrote in message
news:ey**************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #4
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" <wa*****************@mariner-usa.com> wrote in message
news:eL**************@tk2msftngp13.phx.gbl...
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" <pv*@speakeasy.net> wrote in message
news:ey**************@TK2MSFTNGP11.phx.gbl...
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


Nov 18 '05 #5
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" <wa*****************@mariner-usa.com> wrote in message
news:eL**************@tk2msftngp13.phx.gbl...
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" <pv*@speakeasy.net> wrote in message
news:ey**************@TK2MSFTNGP11.phx.gbl...
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


Nov 18 '05 #6
Peter, I'm glad you have it working now.

--
Best regards,
Jeffrey Palermo
Blog: http://dotnetjunkies.com/weblog/jpalermo
"Peter Afonin" <pe***@gudzon.net> wrote in message
news:OA**************@tk2msftngp13.phx.gbl...
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" <wa*****************@mariner-usa.com> wrote in message
news:eL**************@tk2msftngp13.phx.gbl...
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" <pv*@speakeasy.net> wrote in message
news:ey**************@TK2MSFTNGP11.phx.gbl...
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



Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Maxim Vexler | last post by:
Hello to everyone, Assuming i have this simple script : <?PHP //Opening tag =' $html_header=' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"...
1
by: Søren Schimkat | last post by:
Hej Guys I´m stuck with af problem. I need to replace the HTML code in at table cell with some other HTML code. Could you please give me a hint on how to do that? Regards Søren Schimkat
0
by: Lee Swanson | last post by:
Hi, Can anyone tell me of a way to generate an screen capture of some html code server-side? Obviously the code would have to be rendered, then a screen capture made. I am thinking that...
4
by: Rosau | last post by:
I create a table dynamically using VB, How do I get HTML code for that table into a string variable ??? any sugestion, Thanks
6
by: Ros_Au | last post by:
I create a table dynamically using VB, How do I get HTML code for that table into a string variable ??? any sugestion, Thanks!!!
2
by: _MC_ | last post by:
Hi, i want to structure two elements (each conists of 1 Label and 1 Textbox) in an Table. As I use an Content Place Holder, i thought it is possible to add the table via Controls.add(Literal)....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.