Advertisement
1_2002 Databases/ Data Access/ DAO/ ADO #104147

Aprostrophe

Have you ever try so send a string variable to MS Access that have apostrophes using a SQL Statement? If YES you will get a run time ERROR Here is your solution....A function that formats the variable before sending it to the database.

AI

ИИ-обзор: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Исходный код
original-source
'***********************************************************************
' Function: Apostrophe
' Argument: sFieldString
' Description: This subroutine will fill format the field we
' want to store in the database if there is some apostrophes
' in the field.
'***********************************************************************
Public Function Apostrophe(sFieldString As String) As String
If InStr(sFieldString, "'") Then
  Dim iLen As Integer
  Dim ii As Integer
  Dim apostr As Integer
  iLen = Len(sFieldString)
  ii = 1
  Do While ii <= iLen
   If Mid(sFieldString, ii, 1) = "'" Then
   apostr = ii
sFieldString = Left(sFieldString, apostr) & "'" & _
Right(sFieldString, iLen - apostr)
   iLen = Len(sFieldString)
   ii = ii + 1
   End If
   ii = ii + 1
  Loop
End If
Apostrophe = sFieldString
End Function
Оригинальные комментарии (3)
Восстановлено из Wayback Machine