Android Question parallel key for "

Kiran Raotole

Active Member
Licensed User
I'm trying to insert record in sqlite my code is :

tr.ExecNonQuery("INSERT INTO gl (fdesc) VALUES ('" & desc & "')")

fdesc has value = VASANT'S THE SUPER SHOP

Log is : android.database.sqlite.SQLiteException: near "S": syntax error (code 1): , while compiling: INSERT INTO gl (fdesc) VALUES ('VASANT'S THE SUPER SHOP')
 
Im using this command :
tr.AddNonQueryToBatch("INSERT INTO gl (fdesc) VALUES (?)", "111111111")
But its not add any record

whats problem?
 
Upvote 0
Upvote 0
sorry i dont understand by this. I have to just insert record in my sqlite table where value store in variables

i have no problem with : tr.ExecNonQuery("INSERT INTO gl (fdesc) VALUES ('" & desc & "')")

but only problem is desc variable contain ' symbol
 
Upvote 0
Code: Copy
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        mSQL.Initialize(File.DirInternal, "test.db", True)
    End If
    Dim desc As String = "Vasant's the super shop"
    mSQL.ExecNonQuery("CREATE TABLE IF NOT EXISTS Table1 (ID INTEGER, Name TEXT)")
    mSQL.ExecNonQuery2("INSERT INTO Table1 VALUES (?, ?)", Array As Object(1, desc))
    Log(mSQL.ExecQuerySingleResult("SELECT Name FROM Table1 WHERE ID = 1"))
End Sub

This code logs "vasant's the super shop" with no issue parsing the '. You should either clean the string of any invalid character or disallow the user to input them or change:

tr.ExecNonQuery("INSERT INTO gl (fdesc) VALUES ('" & desc & "')")
TO
tr.ExecNonQuery2("INSERT INTO gl (fdesc) VALUES (?)", Array As Object(desc)
 
Upvote 0
Back
Top