VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This is a function to format field strings that contain apostrophes for processing by an SQL server

by Jonathan Wareham (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Sat 2nd October 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This is a function to format field strings that contain apostrophes for processing by an SQL server.

Rate This is a function to format field strings that contain apostrophes for processing by an SQL server



    ' Format Apostrophes For SQL Statement
    Dim ChrPos As Long, PosFound As Long
    Dim WrkStr As String
    For ChrPos = 1 To Len(StrFieldVal)
        PosFound = InStr(ChrPos, StrFieldVal, "'")
        If PosFound > 0 Then
            WrkStr = WrkStr & Mid(StrFieldVal, ChrPos, PosFound - ChrPos + 1) & "'"
            ChrPos = PosFound
        Else
            WrkStr = WrkStr & Mid(StrFieldVal, ChrPos, Len(StrFieldVal))
            ChrPos = Len(StrFieldVal)
        End If
    Next ChrPos
    FormatSQL = WrkStr
End Function

Download this snippet    Add to My Saved Code

This is a function to format field strings that contain apostrophes for processing by an SQL server Comments

No comments have been posted about This is a function to format field strings that contain apostrophes for processing by an SQL server. Why not be the first to post a comment about This is a function to format field strings that contain apostrophes for processing by an SQL server.

Post your comment

Subject:
Message:
0/1000 characters