Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to save HTML into MS SQL?

Status
Not open for further replies.

ombina

Programmer
Jun 18, 2002
62
US
Hello,

What is the proper coding to save HTML into SQL? I am planning to save a complete HTML page code and paste into the database.

Thanks,

Ricky Thanks,

Ricky Ombina
ombina@yahoo.com
 
Do you mean writing a page to put another page into the db?
Well you can use either the FileSystemObject or the XMLHTTP object to get the contents of the file. After that it is the same as saving any string to the database, only it is going to be somewhat longer than a username or password ;)

FileSystemObject would be if the file is local (on the server), XMLHTTP would be if the file is ona remote server, it could also be used locally but I would suggest going with FSO unless you just want the functionality for either local or remote reading.

If I mistook what you said and you wanted to physically copy and paste, than all you shoud need to do is make sur there is a field that is set up to receive it, ie probably need more than 1000 characters, possibly 2000+ depending on how long these pages are.

Hope this helps,
-Tarwn ________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
gsc1ugs and Tarwn,

It is a cut and paste HTML into a TEXT datatype in MS SQL database.

I have to go try and replace the < and > because what's odd is that the data are saved into the database but it's creating an error during INSERT. All I know is that I can see all the HTML codes and actually viewable web page when I read the DB field.

Thanks,

Ricky Thanks,

Ricky Ombina
ombina@yahoo.com
 
I believe he means &amp;lt; and &amp;gt; for &lt; and &gt;

In order to type those in posts you need to type &amp;&amp;lt; so the ampersand will be resolved to an ampersand instead of resolving the lt; with the ampersand.

On inserting: Are you sure its the brackets that is messing it up? My first guess would be that you have single or double quotes that could be causing problems. I have a database for my resources web site that is chock full of &lt;'s and &gt;'s and it doesn't complain at all.

Try simply inserting something like a body tag(with no attributes in the tag, just &lt;body&gt;) and see if it complains.

-Tarwn ________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
It may be that I did not account double quotes?

I only have this:

txtHTML = replace(request.form(&quot;htmlCodes&quot;),&quot;'&quot;,&quot;''&quot;)

If I need double quotes, what's the line for that? I'm having a tough times converting the &quot; into chr funtion.

Thanks again.

Ricky Thanks,

Ricky Ombina
ombina@yahoo.com
 
Well it shouldn't be a problem, it may depend on what db your using. Again try it with something small and build it up. Start with a body tag, then maybe try a body tage with a bgcolor attribute set, etc. When it starts to fail you'll have your answer :)

the ampersand thing should have been:
&amp;amp; by the way...
hopefully that will show correctly.
________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top