472,123 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Replacing Quotation marks in SQL

1
Hi.

I came across this site while looking for a function to replace Quotation marks in SQL.

This is my code.

<!-- Begin Code -->

Intro = Replace(Intro,"'","''")
Text = Replace(Text,"'","''")



SQL = "Insert Into Articles(AuthorId,CatId,TopstoryId,Headline,Subhea dline,Intro,Text) Values ('" & Request("AuthorId") & "','" & Request("CatId") & "','" & Request("TopStoryId") & "','" & Request("Headline") & "','" & Request("Subheadline") & "','" & Intro & "','" & Text &"')"

<!-- End Quote -->


Now the problem I have is that when I execute my sql server statement no value is written in the database for Intro and Text, can anyone see where I am going wrong?
Mar 6 '07 #1
1 1639
dorinbogdan
839 Expert 512MB
Text could be a reserved word, use other var name instead, i.e. strText:
Expand|Select|Wrap|Line Numbers
  1. Intro = Replace(Intro,"'","''") 
  2. strText = Replace(strText,"'","''")
  3.  
  4. SQL = "Insert Into Articles 
  5.      (AuthorId, CatId, TopstoryId, Headline, Subheadline, Intro, [Text]) 
  6.     Values ('" & Request("AuthorId") & "','" & 
  7.              Request("CatId") & "','" & 
  8.                            Request("TopStoryId") & "','" & 
  9.              Request("Headline") & "','" & 
  10.               Request("Subheadline") & "','" & 
  11.              Intro & "','" & 
  12.               strText & "')"
  13.  
Mar 6 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by J. Muenchbourg | last post: by
8 posts views Thread by Stephen Poley | last post: by
63 posts views Thread by Tristan Miller | last post: by
4 posts views Thread by Thomas Miskiewicz | last post: by
reply views Thread by Aaron Deskins | last post: by
31 posts views Thread by The Bicycling Guitarist | last post: by

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.