|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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. |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Saving (') appostrophe in DB |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|