Inserting data into Sqlite DB

I try to insert numeric values (as strings) into an SQLite DB using
Dim bql As String
bql = “INSERT INTO TBigl (Data, NBigl, Lord, Net, IVA) VALUES ( ‘c.D_DATA’, ‘c.N_BIGL’, ‘c.LORD_B’, ‘c.NET_B’, ‘c.IVA_D_B’ );” //Istruzioni specifiche di bqlite

DB.sqlExecute(bql)

where c.XXX are strings representing numerical values.

What I get is a row populated with the names c.XXX as in the attached picture.
How can I write the respective values instead of the names of the globals?

Thank you

Change to:

" ... VALUES (" + c.D_DATA + ", " + c.N_BIGL + ", " ...

To be clear, you have in your code properties like c.D_DATA that contain numerical values and you are trying to insert those values into your record?

bsql = "INSERT INTO Tbigl (Data, NBigl, Lord, Net, IVA) VALUES ( ?, ?, ?, ?, ? );"
DB.ExecuteSQL( bsql,  c.D_DATA, c.N_BIGL, c.LORD_B, c.NET_B, c.IVA_D_B )
1 Like

Even better, do what Kem says :slight_smile:

He typed faster than I.

2 Likes

I should have that made into a bumper sticker. :grinning:

2 Likes

Thank you Guys, great as usual, it solved one of my (many) problems, I’m very green in Xojo and especially with SQLite DB.
I’d like to take the opportunity to ask another thing: if you have a DB with two tables, how do you manage the? Do you need 2 sqliteDatabase properties or you can work just with a single one?
I tried with 1 property but keep on getting errors while working with the second table

I don’t understand the question. Can you post the code you’re trying?

I uploaded the project I’m trying to do (https://www.transfernow.net/gzoomP022021).
I’m sorry it is in italian.
Basically, it should keep track of events by recording number of tickets (biglietti) and number of meals served (cene) with dates and whatever incomes have been gained (gross (lordo), net and taxes (iva)).
If I deal with the top listbox only, with your suggestions, I can make it work - more or less. Adding the bottom one I get some errors when writing and/or retrieving the database

If I understand you, you have to do two INSERTs.

Yes, into two different tables and, of course later on, two retrieves from them

Never mind my question: there was an extra “l” in the code specifying the name of the column. That was the glitch preventing it from working.
Sorry about that

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.