Jump to content

how to insert ' character in sql


Recommended Posts

Example code 

$adoCon = ObjCreate("ADODB.Connection")
$adoRs = ObjCreate ("ADODB.Recordset")
$adoRs.CursorType = 1
$adoRs.LockType = 3
$adoCon.Open("Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & @ScriptDir&"\data.mdb;") ;Use this line if using MS Access 2003 and lower

;$string = "ABCDEF"     ; not error
$string = "AB'CDEF"     ; error

$adoCon.execute( "INSERT INTO STR VALUES ('" &$string& "')")

$adoCon.Close

Help me  this code. Get error if ' character in $string  

Thank . 

 

Edited by 123disconnect
Link to comment
Share on other sites

From SQLite.au3 :

Func _SQLite_FastEscape($sString)
    If IsNumber($sString) Then $sString = String($sString) ; don't raise error if passing a numeric parameter
    If Not IsString($sString) Then Return SetError(1, 0, "")
    Return ("'" & StringReplace($sString, "'", "''", 0, $STR_CASESENSE) & "'")  ;$STR_CASESENSE = 1
EndFunc   ;==>_SQLite_FastEscape

 

Edited by mikell
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...