Link to home
Create AccountLog in
Avatar of Bob Schneider
Bob SchneiderFlag for United States of America

asked on

Can't remove single quote

Can someone tell me why this code won't replace single quotes with a pair of single quotes?

	Dim sFldVal
	
	Set rs = Server.CreateObject("ADODB.Recordset")
	sql = "SELECT Comments FROM GrdbkRprtStdnts ORDER BY Comments"
	rs.Open sql, conn, 1, 2
	Do While Not rs.EOF
		sFldVal = rs(0).Value

		If Not sFldVal & "" = "" Then 
			sFldVal = Replace(sFldVal, "'", "''")
			rs(0).Value = sFldVal
			rs.Update
		End If
		rs.MoveNext
	Loop
	rs.Close
	Set rs = Nothing

Open in new window


Everytime I run into a single quote it throws an ole db error...:

ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.