B4J Question [SOLVED] SQL.ExecNonQuery2 does not work

Knoppi

Active Member
Licensed User
Longtime User
B4X:
SQL.ExecNonQuery2( "INSERT INTO test VALUES ( ?)", Array As Object( "TEST"))  'this works
SQL.ExecNonQuery2( "INSERT INTO ? VALUES ( 'TEST')", Array As Object( "test"))  'but this fails
org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (near "?": syntax error)

I need a few hints why the second command does not work
 

Daestrum

Expert
Licensed User
Longtime User
I dont think the tablename can be a parameter.
You could use something like
B4X:
Dim Table_Name as String = "test"
…
SQL.ExecNonQuery2( $"INSERT INTO ${Table_Name} VALUES (?)"$, Array As Object( "TEST"))
 
Upvote 0
Top