473,549 Members | 4,476 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=&qu ot;0" cellPadding=&qu ot;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 8976
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******** ******@TK2MSFTN GP11.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=&qu ot;0&quot; cellPadding=&qu ot;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******** ******@TK2MSFTN GP11.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=&qu ot;0&quot; cellPadding=&qu ot;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******** ******@TK2MSFTN GP11.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=&qu ot;0&quot; cellPadding=&qu ot;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******** ******@tk2msftn gp13.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******** ******@TK2MSFTN GP11.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=&qu ot;0&quot; cellPadding=&qu ot;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******** ******@tk2msftn gp13.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******** ******@TK2MSFTN GP11.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=&qu ot;0&quot; cellPadding=&qu ot;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.n et> wrote in message
news:OA******** ******@tk2msftn gp13.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******** ******@tk2msftn gp13.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******** ******@TK2MSFTN GP11.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=&qu ot;0&quot; cellPadding=&qu ot;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
8830
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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1
1528
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
962
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 perhaps an element of internet explorer could be used to do this. Anyway, at first glance this seems near impossible, but I thought I would
4
2679
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
1763
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
14992
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). Literal consists of standard html code like <table>, <tr>, etc.. Nevertheless Asp Net generates me now table in html code, maybe you see my mistake...
0
7526
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7455
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7723
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7962
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7480
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7814
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5373
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5092
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.