Sql query with dbf [solved] lazarus / 16-Databases ---------------------------------------------------------------------- Cz-David · 2008-02-24 09:49 Can someone show me (step by step) how to connect sql query component to tdbf. I have tried everything and looked everywhere (i hope) but I still get "database not assigned" error. Let's say that I have a table with 2 columns. Id -autoincrement otazka -string How can I transfer otazka with id=2 to label or variable. Thanks. ---------------------------------------------------------------------- gerardus · 2008-02-24 11:05 Hi, AFAIK SQL querys only work with SQL database backends. TDBF reads/writes DBF flat files and has no support for SQL. Regards, Gerard. ---------------------------------------------------------------------- Cz-David · 2008-02-24 11:20 That's bad... So what do you recommend for a database? Where i can use sql select to work with variables. But I certainly don't want to use server but files. Even though most of my program's targeted end users has access to such technology, it's just not very user-friendly. And I don't want users to install extra files for work with databases. Edit: SQLite looks good. ---------------------------------------------------------------------- Cz-David · 2008-02-24 14:19 I have succesfully converted my app to sqlite, but I still don't know how to get data from db to variable... sql query is still in "database not assigned" error... what should I do ? ---------------------------------------------------------------------- Cz-David · 2008-02-24 14:29 Code: [Select] label1.caption:=sqlite.QuickQuery('SELECT otazka FROM Otazky where id=0'); works ---------------------------------------------------------------------- OnixJr · 2008-02-24 15:22 QuoteI have succesfully converted my app to sqlite, but I still don't know how to get data from db to variable... How do you do with TDbf? I always do (in SQL or TDbf) something as: Code: [Select]   sqlite.recno := 0; // can use next, prior, last, first methods...   label1.caption := sqlite.FieldByName('otazka').AsString; ---------------------------------------------------------------------- Cz-David · 2008-02-24 17:26 I suppose that can work too. ---------------------------------------------------------------------- tatamata · 2008-02-25 11:13 Oh, I see I am not the only one looking SQL engine for TDbf:))) As I see it now, TDbf or any other flat file database (Sdf, for example) has great advantage over SQL servers in terms of portability, easy distribution and modular design when you want to develop cluster of different small front-end programs that operate with same set of data tables. But the great disadvantage is lack of SQL. The solution is to develop an SQL query component (SQL engine) that is TDataset descendant and can query different flat table datasets. There is such component for Delphi, commercial though, called TxQuery... The starting point could be TJanSQL engine... ---------------------------------------------------------------------- gerardus · 2008-02-25 16:49 Before you develop a SQL engine for flat files, you may want to have a look to Firebird. (http://www.firebirdsql.org) ---------------------------------------------------------------------- tatamata · 2008-02-26 18:53 Let's say you develop an application with Firebird embedded for Windows. You created .exe to be distributed with Firebird embedded DLLs for Windows. Your customers want it to be runnable on Linux. OK, you can recompile your application on Linux, but what about Firebird embedded on Linux? What .so files to be distributed? Does it work without Firebird classic or superserver running in background? If not, then it is not true embedded solution.... Regards, Zlatko ---------------------------------------------------------------------- gerardus · 2008-02-27 15:19 Quote from: "tatamata"Let's say you develop an application with Firebird embedded for Windows. You created .exe to be distributed with Firebird embedded DLLs for Windows. Your customers want it to be runnable on Linux. OK, you can recompile your application on Linux, but what about Firebird embedded on Linux? What .so files to be distributed? Does it work without Firebird classic or superserver running in background? If not, then it is not true embedded solution.... Zlatko It seems that a Classic Firebird server can be set up and used as an embedded server (I haven't tried this): http://www.firebirdfaq.org/Firebird-Embedded-Linux-HOWTO.html Adding SQL support to DBF means writing a full SQL engine because DBF so far only gives the minimal features of a SQL engines, that is storage plus limited indexing. It's up to you to make a decision based on what features of a SQL engine you need, (ANSI SQL compliance, stored procedures, generators, triggers, relational integrity...) what degree of "embeddedness" you want, and the cost of writing such a beast by yourself. Regards, Gerard.