elbiel
Programmer
- Dec 9, 2002
- 2
I wrote a function SQLEncode which replaces ' with '' for text containing single quotation marks. The text is then sent as a parameter to a sqlserver stored procedure. I have a problem that stores the '' as part of the text and everytime the record gets updated it adds more ''. In the end there could be zillions of ' sa part of the text.
I have used the function with ASP where a dynamic sql statement was created by code, and it works. It must have something to do with how the stored procedure interprets the parameter value sent.
THE CODE:
Function SQLEncode(ByVal strText As String) As String
SQLEncode = strText
If strText = "" Or IsDBNull(strText) Then Exit Function
SQLEncode = Replace(strText, "'", "''")
End Function
ADING THE PARAMETER:
.Parameters.Add("@Name", SQLEncode(txtName.Text))
THE STORED PROC:
UPDATE [Campaign] SET [Name] = @Name WHERE [ID] = @ID
Any assistance will be appreciated.
I have used the function with ASP where a dynamic sql statement was created by code, and it works. It must have something to do with how the stored procedure interprets the parameter value sent.
THE CODE:
Function SQLEncode(ByVal strText As String) As String
SQLEncode = strText
If strText = "" Or IsDBNull(strText) Then Exit Function
SQLEncode = Replace(strText, "'", "''")
End Function
ADING THE PARAMETER:
.Parameters.Add("@Name", SQLEncode(txtName.Text))
THE STORED PROC:
UPDATE [Campaign] SET [Name] = @Name WHERE [ID] = @ID
Any assistance will be appreciated.