[solved] How to pass the value of a variable to a column ? SQLITE lazarus / 16-Databases ---------------------------------------------------------------------- zoimutante · 2016-04-05 05:42 SQLite3Connection1.ExecuteDirect('insert into DATA (Name,Phone) values ("nome","telefone");'); That is the code, I have 2 variables called nome and telefone, I try to pass the content of the variables to the columns, nome to column Name, and telephone o the column Phone, but it is not happening. The columns are full of "nome" and "telefone", the literal names of the variables, not the contents of it. ---------------------------------------------------------------------- Thaddy · 2016-04-05 05:54 That wrong SQL for what you want. Just use the variable names , no quotes. If the nome and telephone are edit controls refer to the text property. Something like one of these (not tested, but should be close) Code: MySQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i --- as variablesinsert into DATA (name,Phone) values( nome, telephone)--- orinsert into DATA(name,Phone) values (nome.text, telephone.text) ---------------------------------------------------------------------- balazsszekely · 2016-04-05 06:02 To avoid problems, you should always use parameterized queries. Since you want to insert the data directly, try something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  Nome, Telefone: String;begin  Nome := 'John';  Telefone := '0785-343434344l';  SQLite3Connection1.ExecuteDirect('insert into DATA (Name,Phone) values (' + QuotedStr(Nome) + ',' + QuotedStr(Telefone) + ');');end;                                                                                                                                If both fields are varchar it should work. ---------------------------------------------------------------------- zoimutante · 2016-04-05 06:14 Quote from: Thaddy on April 05, 2016, 07:54:06 amThat wrong SQL for what you want. Just use the variable names , no quotes. If the nome and telephone are edit controls refer to the text property. Something like one of these (not tested, but should be close) Code: MySQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i --- as variablesinsert into DATA (name,Phone) values( nome, telephone)--- orinsert into DATA(name,Phone) values (nome.text, telephone.text)  It don't work in my case, at run time i get a error at execution... complain about a there is no column named name... but thank for the fast answer ---------------------------------------------------------------------- zoimutante · 2016-04-05 06:20 Quote from: GetMem on April 05, 2016, 08:02:41 amTo avoid problems, you should always use parameterized queries. Since you want to insert the data directly, try something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  Nome, Telefone: String;begin  Nome := 'John';  Telefone := '0785-343434344l';  SQLite3Connection1.ExecuteDirect('insert into DATA (Name,Phone) values (' + QuotedStr(Nome) + ',' + QuotedStr(Telefone) + ');');end;                                                                                                                                If both fields are varchar it should work. It work but phone column is a integer, and the variable also a integer...  I need to change the type of the variable to work. There is a QuotedInteger, or something like that to pass a integer to the column ? What is parameterized query ? some commands used by tsqlquery ? ---------------------------------------------------------------------- balazsszekely · 2016-04-05 06:28 QuoteIt work but phone column is a integer, and the variable also a integer...  I need to change the type of the variable to work.See my comment about parameterized queries. QuoteThere is a QuotedInteger, or something like that to pass a integer to the column ?There is no such thing as QuotedInteger. Try this(cross your fingers ) : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var   Nome: String;   Telefone: Integer;begin   Nome := 'John';   Telefone := 123455656;   SQLite3Connection1.ExecuteDirect('insert into DATA (Name,Phone) values (' + QuotedStr(Nome) + ',' + IntToStr(Telefone) + ');');end;  QuoteWhat is parameterized query ? some commands used by tsqlquery ?Yes! Please read this: http://wiki.freepascal.org/Working_With_TSQLQu ery#TSQLQuery.InsertSQL.2C_TSQLQuery.UpdateSQL_and_TSQLQuery.DeleteSQL :_Basic_Use_of_Parameters ---------------------------------------------------------------------- Thaddy · 2016-04-05 06:56 As I wrote I didn't test it, but indeed it should be (in the case of variables): Code: MySQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i insert into DATA (name,Phone) values( :nome, :telephone)  I wonder if that works with executedirect, though. I think you should use an SqlQuery or the like for that to work.