123disconnect Posted March 28, 2016 Posted March 28, 2016 (edited) 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 March 28, 2016 by 123disconnect
maniootek Posted March 28, 2016 Posted March 28, 2016 (edited) according to post I found from here: http://stackoverflow.com/questions/11255367/sql-select-statement-the-thing-i-am-querying-for-has-a-single-quotation-mark try this $string = "AB''CDEF" ; error Edited March 28, 2016 by maniootek
mikell Posted March 28, 2016 Posted March 28, 2016 (edited) 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 March 28, 2016 by mikell
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now