Problem inserting text in Sql Server
Author: Toshit Bhardwaj
Rating:
Visits: 3873
Discuss in Newsgroups
You might have experienced a problem in inserting a text in sql server through web page.
Problem occurs when you try to insert something like this " hello world's ".
Because you are trying to insert ( ' ) n the string, because sql server interpret it as a termination of string.
Try to insert "hello's world's" , you won't be having any problem.
To solve this problem, we can use this function , which creats one more ( ' ) at the end of the string and makes it according to sql server.
function padQuotes( instring )
Dim bodybuild
Dim bodystring
Dim Length
Dim i
bodybuild = ""
bodystring = instring
Length = Len(bodystring)
For i = 1 to length
bodybuild = bodybuild & Mid(bodystring, i, 1)
If Mid(bodystring, i, 1) = Chr(39) Then
bodybuild = bodybuild & Mid(bodystring, i, 1)
End If
Next
bodystring = bodybuild
padQuotes = bodystring
End function
Visit my guru profile
Visitor Comments