Android Question SQLite Insert Question

AndyChang

Member
Licensed User
I try to Insert an Text Variable (item number) into SQLite.

I use two types of way to INSERT data

1. SQL1.ExecNonQuery2("INSERT INTO " & TableName & " VALUES (?,?)", Array As String(1, "itemNBR"))

2. SQL1.ExecNonQuery("INSERT INTO " & TableName & " VALUES (Null, 'itemNBR')")

I got the same results. The data which store in Sqlite is the String “itemNBR”. But I need "FMAS-2101".

What’s wrong with my code?

Andy
 

Attachments

  • SQLtestRW.zip
    8.8 KB · Views: 177

DonManfred

Expert
Licensed User
Longtime User
The data which store in Sqlite is the String “itemNBR”. But I need "FMAS-2101".
Why are you using itemNBR then?
B4X:
SQL1.ExecNonQuery2("INSERT INTO " & TableName & " VALUES (?,?)", Array As String(1, "itemNBR"))
You are giving the values to insert in the Array As String... In this case 1 for the id and itemNBR for the string....
 
Upvote 0

AndyChang

Member
Licensed User
Dear Manfred,
Thanks a lot for your so quick response to my problem.
I change the code as shown in the my attached png. It can't pass the compile stage. Error message as attached png.
Andy
 

Attachments

  • Code changed.png
    Code changed.png
    36.3 KB · Views: 168
  • Error Msg.png
    Error Msg.png
    64.7 KB · Views: 192
Upvote 0

klaus

Expert
Licensed User
Longtime User
I suppose that itemNBR is a variable.
So, remove the double quotes around itemNBR and replace String by Object, it should be:
SQL1.ExecNonQuery2("INSERT INTO " & TableName & " VALUES (?,?)", Array As Object(1, itemNBR))
 
Upvote 0
Top