A AndyChang Member Licensed User Aug 16, 2017 #1 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 SQLtestRW.zip 8.8 KB · Views: 365
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
DonManfred Expert Licensed User Longtime User Aug 16, 2017 #2 AndyChang said: The data which store in Sqlite is the String “itemNBR”. But I need "FMAS-2101". Click to expand... Why are you using itemNBR then? Code: Copy 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 said: The data which store in Sqlite is the String “itemNBR”. But I need "FMAS-2101". Click to expand... Why are you using itemNBR then? Code: Copy 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....
DonManfred Expert Licensed User Longtime User Aug 16, 2017 #3 I suggest to use a structure like Code: Copy SQL1.ExecNonQuery2("INSERT INTO " & TableName & " SET idfield=?, stringfield=?;", Array As String(1, "itemNBR")) ' Set 1 into the field idfield, itemNBR into the field stringfield Upvote 0
I suggest to use a structure like Code: Copy SQL1.ExecNonQuery2("INSERT INTO " & TableName & " SET idfield=?, stringfield=?;", Array As String(1, "itemNBR")) ' Set 1 into the field idfield, itemNBR into the field stringfield
A AndyChang Member Licensed User Aug 16, 2017 #4 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 36.3 KB · Views: 515 Error Msg.png 64.7 KB · Views: 545 Upvote 0
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
Erel B4X founder Staff member Licensed User Longtime User Aug 16, 2017 #5 Please post the code and the error message as text. Right click on the logs to copy it. Upvote 0
A AndyChang Member Licensed User Aug 16, 2017 #6 I right click on the logs and choose "copy all to clipboard". Then how can I get the Log file. Andy Upvote 0
A AndyChang Member Licensed User Aug 16, 2017 #7 Dear Erel I meant where to get the log file. Where is the clipboard. Andy Upvote 0
klaus Expert Licensed User Longtime User Aug 16, 2017 #8 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
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))
A AndyChang Member Licensed User Aug 16, 2017 #9 Dear Klaus It works very well. Thanks you so much. Andy Upvote 0