char sHost[] = "Zomaar een hostnaam";
char sPath[] = "Bedenk maar een path als je wilt";
uint16_t sPort = 65535;
char sName[] = "Een hele mooie naam is altijd mooi";
/* Create SQL statement */
/* ==================== */
sql = "INSERT INTO stations(sHost,sPath,sPort,sName) VALUES (?,?,?,?)",(sHost,sPath,sPort,sName);
//sql = "INSERT INTO stations(sHost,sPath,sPort,sName) VALUES ('sHost url','sPath value',80,'sName station')";
The un-commented statement fails
The commented works just fine but is not very flexible.
The error message is:
Opened database successfully
SQL error: NOT NULL constraint failed: stations.sHost
Program ended with exit code: 0
@wildbill
Thanks for the reply, but I don't understand what you mean by formatting the string I wish to put in the db.
"The C library function int sprintf(char *str, const char *format, ...) sends formatted output to a string pointed to, by str."
Can, will, you provide an example please?
char sql[200];
...
sprintf(sql, "INSERT INTO stations(sHost,sPath,sPort,sName) VALUES ('%s','%s','%s','%s')", sHost,sPath,sPort,sName);
your issue with your previous code is that when you do x = (a, b, c); in c++, the compiler evaluates a, b and then c and stores the result of evaluating c into x.
Just to help other people making their search for that "bindings" thing a little easier, I've found this: "https://www.whoishostingthis.com/compare/sqlite/optimize/".
Its a good explanation of What, How and Why. To find information on the working of statements, as usual, mr. G. is your friend.