Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 29th, 2003, 11:31 AM
bourge bourge is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 1 bourge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation Saving (') appostrophe in DB

hello,

i am building an asp page that saves an 5000 + char through a form in a varchar field. This field dosent accept appostrophe (') and i have tried all other fields. They interpret this appostrophe as a command i think. Is there a field type that would work with this or do i need a function to validate this character?? help..

thanks

eric

Reply With Quote
  #2  
Old September 29th, 2003, 12:00 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
With Microsoft databases, you need to convert the single apostrophe to two of them.

A simple asp function could be

Function sqlStr(strIn)
sqlStr = Replace(strIn, " ' ", " ' ' ")
End Function

I added some spaces above for readibility

Reply With Quote
  #3  
Old September 29th, 2003, 04:39 PM
Scorpions4ever Scorpions4ever is offline
Mad Rater
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 126 Scorpions4ever User rank is Corporal (100 - 500 Reputation Level)Scorpions4ever User rank is Corporal (100 - 500 Reputation Level)Scorpions4ever User rank is Corporal (100 - 500 Reputation Level)Scorpions4ever User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 11 h 31 m 44 sec
Reputation Power: 8
Either that, or use placeholders in your SQL statement. I tend to use placeholders, because it lets you avoid all the BS about double-quoting or escaping special characters and gets the database driver to do all the hard work for you.
Code:
' Use ? to denote placeholders 
Cmd.CommandText = "INSERT INTO MyTable (Field1, Field2, Field3) VALUES ( ?, ?, ?)"

' Now set the parameter values
Cmd.Parameters.Refresh
Cmd.Parameters(0) = Var1
Cmd.Parameters(1) = Var2
Cmd.Parameters(3) = Var3

' Now execute the statement
Cmd.Execute


Disclaimer: The above is off the top of my head and is untested code
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Saving (') appostrophe in DB


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT