VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This function will take care of appostrophy when using SQL Statements. Note that when executing SQl

by Issa Fahmy (7 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Tue 14th August 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This function will take care of appostrophy when using SQL Statements. Note that when executing SQl Statements and you happen to be using a

Rate This function will take care of appostrophy when using SQL Statements. Note that when executing SQl



        'Private declarations in the function
        Dim strInString As String, IntPos As Integer, BlnFlg As Boolean
        'strInString is the string to check for appostrophy
        'IntPos is the position where an appostrophy is found
        'BlnFlg is a boolean check that confirms the existance of an appostrophy
        strInString = strInputString
        'Reset Variables
        BlnFlg = False
        IntPos = 1
        'Check if appostrophy exists and handle by introducting another 
        'appostrophy immediately 
        'Note that you check for appostrophy gradually within the string
        Do While Not BlnFlg
            'Check whether there is an appostrophy in the string
            IntPos = InStr(IntPos, strInString, "'")
            'If there is appostrophy then add another immediately
            If IntPos <> 0 Then
                strInString = Left(strInString, IntPos - 1) & "''" & _
                Mid$(strInString,IntPos + 1)
                IntPos = IntPos + 2
            'If there isn't then be happy
            Else
                BlnFlg = True
            End If
        Loop
        'Return the string with appropriate ammendment
        AppendAppostrophy = strInString
End Function


Download this snippet    Add to My Saved Code

This function will take care of appostrophy when using SQL Statements. Note that when executing SQl Comments

No comments have been posted about This function will take care of appostrophy when using SQL Statements. Note that when executing SQl. Why not be the first to post a comment about This function will take care of appostrophy when using SQL Statements. Note that when executing SQl.

Post your comment

Subject:
Message:
0/1000 characters