SQlite ,printing,distributing and my questions lazarus / 13-General ---------------------------------------------------------------------- tommassino · 2007-01-05 17:43 Hi i have installed sqlite component and create a databse file and created a simpe program that shows all data in a tabel . but i dont know how to assign a sql query to a button.i want to have special button for inserting values and i also want to us some condition like where and functions like sum() i dont know how sho me please a source thank you ---------------------------------------------------------------------- matthijs · 2007-01-05 18:52 What is your intention by assigning a sqlquery to a button? Should the sqlquery be executed or opened after a click on the button? Or do you want anything else. To have a button to insert values do this: Put a SQLQuery on your form and make its SQL.Text like: Code: [Select]insert myTable (Field1, Field2, Field3) values (#field1#, #field2#, #field3#) Then in the OnClick-event of your button change replace the tekst surrounded by hashes (and the hashes) with the reuqired values and call SQLQuery.ExecSQL. Using where and sum is easy. Just place the SQL statement in the SQL.Text property of your SQLQuery and call SQLQuery.Open You can use every SQL-statement you like. So it is possible to make the SQL.Text like: Code: [Select] select sum(Field1) as total from aTable where Field2 in (select aID from anotherTable where (aID > 100) and (aID < 150)) ---------------------------------------------------------------------- tommassino · 2007-01-05 19:17 Quote from: "matthijs"What is your intention by assigning a sqlquery to a button? Should the sqlquery be executed or opened after a click on the button? Or do you want anything else. To have a button to insert values do this: Put a SQLQuery on your form and make its SQL.Text like: Code: [Select]insert myTable (Field1, Field2, Field3) values (#field1#, #field2#, #field3#) Then in the OnClick-event of your button change replace the tekst surrounded by hashes (and the hashes) with the reuqired values and call SQLQuery.ExecSQL. Using where and sum is easy. Just place the SQL statement in the SQL.Text property of your SQLQuery and call SQLQuery.Open You can use every SQL-statement you like. So it is possible to make the SQL.Text like: Code: [Select] select sum(Field1) as total from aTable where Field2 in (select aID from anotherTable where (aID > 100) and (aID < 150)) thank you for the answer i was plaing and changed execsql to open and it is working ---------------------------------------------------------------------- tommassino · 2007-01-06 10:50 how to set automatic (ot just edit) width of columns in dbgrid ?? ---------------------------------------------------------------------- tommassino · 2007-01-06 12:37 1. my dbgrid is not showing dates from the column date.the type is date and in sqlite command its showing everything ok but not in dbgrid 2. And Do you know how to print the result of query in some template? like Quotesome text blablabla result of query in dbgrid another text +datum and so on 3.How to distribute the package to everyone (with needed packages like sqlite ) could open the program an be working.and how to set the filename of sqlite file to the actual directory location . understand: i have all lazarus files with sql file of database in one directory and i want to just copy the directory to my fathers pc to he could use it right away(of course after compilation) a saw a wiki tutorial for making makefile but it seems me strange because everyone who would want to use my app would have to have lazarus with all my components installed (if i understanded well) please write your own step by step howto to make makefile ---------------------------------------------------------------------- bobix · 2008-05-01 15:58 Quotemy dbgrid is not showing dates from the column date.the type is date and in sqlite command its showing everything ok but not in dbgrid Does anyone know the solution of this problem? SOLUTION: replace datefield with strftime("%Y-%m-%d", ...) example: SELECT strftime("%Y-%m-%d", datfield) as datfield FROM table