473,672 Members | 2,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3109

"Mitch Abaza" <sds@dsd> wrote in message
news:3f******** **@newspeer2.td s.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("ins ert into foo(v) values (@v)");
cmd.parameters. add(. . .

cmd.ExecuteNonQ uery()

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.td s.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)i nova.ch
Nov 15 '05 #4

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

Similar topics

0
1944
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: Incorrect syntax near 'Tryk'. (SQL-42000)(DBD: Execute immediate failed err=-1) at spider.pl line 175.
14
4060
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 generating the 327 passwords, but have had no luck inserting them. =============================================== Here is the code that generates the passwords: =============================================== <% Option Explicit %>
5
1398
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) with various text boxes and drop-downs + tick boxes. Then i want to click a submit button that inserts the data (providing is valid) into a SQL Server table.
3
4248
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 the rate for a certain size, "from:" address, "To:" address and delivery service speed. The examples they showed used a HTML "Text Area" and a HTTP post statement to send the request however I need to use input from an input box and then insert...
3
2448
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 parameter I'm using is > cmd.Parameters.Add(New SQLParameter("@thedate", thedate.text))
2
2572
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 test(name,surname,email) VALUES('Bob', 'Sly', 'bobsly@yahoo.com')"; but instead of inputing the values directly, I want to insert them as variables like so:
4
1485
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 the data to sql server 2005 . A error message occurs saying "@vfirstname" is not declared. I donot understand where do i declare the parameter and how? How do i insert data using stored procedure? Please guide me as early as possible. Do write...
25
3081
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 have the Error . The Error appears when I press submit button . But when i just call it using this url http://10.164.1.86/lala.asp . It produce the massege i want it to produce after inserting the information. Hope you can help . My Code looks this...
2
3112
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 record. My code inserts records one by one using addnew-updatebatch. If there is a duplicate in the db, it will display "already exists" and if it is not in the db it will display "record added". Below is my asp code I found on the net and...
0
8486
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8404
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8828
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8680
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7446
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6238
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5705
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4418
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.