473,405 Members | 2,445 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,405 software developers and data experts.

inserting HTML into SQL Server

I've got a simple SQL Server 2000 table with an ntext field defined and I'm
having a heck of a time inserting html into it. Everytime I try, I get an
ADO.NET error complaining about invalid syntax because its trying to parse
out the various HTML tags (>,<,+, =) and it's puking. Is there a way to
disable this behavior?

Thanks!
Nov 15 '05 #1
3 3081

"Mitch Abaza" <sds@dsd> wrote in message
news:3f**********@newspeer2.tds.net...
I've got a simple SQL Server 2000 table with an ntext field defined and I'm having a heck of a time inserting html into it. Everytime I try, I get an
ADO.NET error complaining about invalid syntax because its trying to parse
out the various HTML tags (>,<,+, =) and it's puking. Is there a way to
disable this behavior?


Don't try to build a SQL query to insert it.

Use a command with a parameter, instead.

SqlCommand cmd = new SqlCommand("insert into foo(v) values (@v)");
cmd.parameters.add(. . .

cmd.ExecuteNonQuery()

David
Nov 15 '05 #2
Are you passing in your HTML as a Parameter? It should escape it if you do,
however your length will be limited by the DB field. You may also want to
try storing it as binary...it shouldn't bark at you and you can get quite a
bit of data into it.
"Mitch Abaza" <sds@dsd> wrote in message
news:3f**********@newspeer2.tds.net...
I've got a simple SQL Server 2000 table with an ntext field defined and I'm having a heck of a time inserting html into it. Everytime I try, I get an
ADO.NET error complaining about invalid syntax because its trying to parse
out the various HTML tags (>,<,+, =) and it's puking. Is there a way to
disable this behavior?

Thanks!

Nov 15 '05 #3
>Don't try to build a SQL query to insert it.

Use a command with a parameter, instead.


Or better yet - use a stored procedure to insert and retrieve the HTML
stuff !

Marc
================================================== ==============
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
Nov 15 '05 #4

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

Similar topics

0
by: Kristian | last post by:
Hi Guys, I have a script that has to insert an var containing a html string into my microsoft sql server, and it keeps throwing the same error at me. DBD::ODBC::db do failed: Line 89:...
14
by: Miranda | last post by:
Hi, I have a ASP/vbscript program that generates random passwords. The problem is I need to insert those passwords into an Access database of 327 clients. I have the random password program...
5
by: Fawke101 | last post by:
Hi there, I am new to ASP and i have really only been exposed to getting data from a SQL database and displaying it. I want to include a page in my application (like a form in Access i guess)...
3
by: Geoff | last post by:
I have been asked to add postal rates to a web page shopping cart checkout procedure. After contacting the post office I discovered that they used XML to receive postal rate requests and send back...
3
by: J. Muenchbourg | last post by:
while inserting new records into SQL, i'm using the folloinwg sqlstatement> Dim MySQL as string = "Insert into roster (pname, pnotes, thedate) values (@pname, @pnotes, @thedate)" the sql...
2
by: altergothen | last post by:
Hi there I am a newbie to ASP.Net - Please Help! I am trying to insert the values of my variables into a database. If I try the following it works perfectly: string insertQuery = "INSERT into...
4
by: itsnidhu | last post by:
Hi this is nidhi from india, Since last 2 days i am facing a problem in asp.net code. The data base connection is done correctly as i can select the data from the database. But i can not insert...
25
by: bseakgano | last post by:
I have developed a intranet . Using HTML , SQL and ASP . I have created a table with SQL is just fine . And design a form is just looks fine to me . But when I try to insert Data into the SQL I just...
2
by: hakkatil | last post by:
Hi to all, I have a page that inserts excel sheet to access database. I am using asp. What I want to do is to check the inserting record if it is in the database. Basicly checking the dublicate...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.