Sign in Join
Wiki copytemporary

Lazarus Database Tutorial/zh CN: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## 概述
22
33本教程是讲述在Lazarus 下如何为流行的多种数据库开发应用程序。
44
55Lazarus 支持多种数据库的‘开箱即用’,当然,开发者必须预先安装要使用的数据库系统。访问数据库,要么通过编写代码实现,要么通过可视化的拖拉控件到窗体来实现。数据感知(data-aware)控件将DataSource 属性指向TDataSource 控件,就能显示数据库字段内容. Datasource 控件将DataSets 属性连接到 database类组件(例如:TPSQLDatabase,TSQLiteDataSet),就能显示表的内容. 数据感知组件位于“数据控制(Data Control)”标签页。数据源(Datasource)和数据库控件位于“数据操作(Data Access)”标签。
66
77## Lazarus 和 MySQL
88
99### 在Lin或Win下使MySQL工作
1010
1111跟随小麦用户手册的介绍,确认小麦的守护进程(服务)运行可靠,并且所有潜在用户(包括:root、mysql、你自己还有任何需要的人)拥有他们需要的权限,来自多个主机或许(包括‘localhost’,本地主机名,任何其他主机在你的网络上)足够安全。最好包括root在内的所有账户都有密码。用手册中的例子测试数据库系统的动作,并且检查所有用户真的能够可靠存取。
1212
1313### 从FPC文本模式连接MySQL
1414
1515(Get MySQL working for FPC in text mode)
1616
1717(译注:略,请参见英文页面) See [[Lazarus Database Tutorial/SampleListing|Sample Console Listing]].
1818
1919### 从Lazarus程序连接到MySQL
2020
2121该教程显示如何连接辣子到小麦数据库,并且执行一个简单的查询,仅使用基本的辣子组件;这里没有用到数据感知组件,但能更好得阐述连接数据库接口的原理。
2222
2323#### 界面部分
2424
2525在辣子中创建一个新项目:
2626
27-`Project -> New Project -> Application`
27+```text
28+Project -> New Project -> Application
29+```
2830
2931将出现一个自动生成的窗体。缩放窗体至半个屏幕大小,然后重命名窗体的标题为‘TryMySQL’(译注:随便起个名字,和下面一致就行)。
3032
3133程序界面截图:
3234
3335![](/wiki-images/8/81/Lazarusmysqldb.png)
3436
3537程序界面设计过程如下:
3638
3739自标准组件标签页拖放三个编辑框(Edit Boxes)到表单的左上侧,然后马上给上面每个box一个标签(Label)。改变名字(name)和标题(caption)为‘Host’(还有HostLLabel,HostEdit),‘UserName’(还有UserLabel,UserEdit),‘Password’(在Passwdlabel和PasswdEdit,似乎是具体组件的属性值)。或者你还可以从额外的标签(Additional tab)中使用LabelledEdit组件。
3840
3941选择Passwd Edit按钮,并且找到 PasswordChar 属性:改变它为 * 符号或者类似的字符,这样,当你键入密码时,字符就不会显示在你的屏幕上,而是反映一系列的星号(x)。确认每一个编辑框的Text属性是空的。
4042
4143现在,放置另一个 Edit 盒子,并且label at 在你表单的右上角。改变标签为‘输入SQL命令吧’(Enter SQL Command),然后命名它为CommandEdit。
4244
4345放置三个按钮在表单上:两个在编辑框的左下脚,一个在右侧,命令行的下方。
4446
4547设置左侧的按钮为‘Connect to Database连接数据库’(ConnnectButton)和‘Exit退出’(ExitButton),右侧的按钮为‘Send Query递交查询’(QueryButton)。
4648
4749放置一个大的 备注框(Memo Box)标记命名为‘Results结果’(ResultMemo),在右下脚,填充所有空白位置。找到 ScrollBars(滚动条)属性,并且选择 ssAutoBoth (双向自动)以保证滚动条自动出现,当文本充满空间时。使 WordWrap(分词)属性为真。 (译注:说了这么多,不如先来一张图)
4850
4951放置一个Status Bar(状态条,从 Common Controls tab通用控制标签)到表单底部,命它的 SimpleText 属性为‘TryMySQL’(这个名字前面出现过)。
5052
5153#### 代码部分
5254
5355现在,我们需要写一些事件处理。
5456
5557左侧三个编辑框需要输入主机、用户名和密码。当这些被满意得输入后,点击连接按钮。该按钮的OnCLick 事件程序(event handler)是基于上文中 FPC文本模式中的一部分。(译注:略掉了,还要吗?)
5658
5759The responses from the database cannot now be written using the Pascal write or writeln statements: rather, the replies have to be converted into strings and displayed in the Memo box. Whereas the Pascal write and writeln statements are capable of performing a lot of type conversion 'on the fly', the use of a memo box for text output necessitates the explicit conversion of data types to the correct form of string, so Pchar variables have to be converted to strings using StrPas, and integers have to be converted with IntToStr. 来自数据库的响应现在还不能写,用Pascal写,或者写成(writeln)报表(statements):因为(rather),结果必须被转换为字串并显示在Memo框内。但是Pascal写和writeln语句是……大量类型转换‘,用memo况来显示文本需要详细地转换数据类型,正确的表单字串,所以,Pchar变量必须转换为字串,用 StrPas,整数用IntToStr转换。
5860
5961在Memo框中显示字符串需要:
6062
61-`procedure ShowString (S : string);`\
62-`(* display a string in a Memo box *)`\
63-`begin`\
64-`       trymysqlForm1.ResultsMemo.Lines.Add (S)`\
65-`end;`
63+``` pascal
64+procedure ShowString (S : string);
65+(* display a string in a Memo box *)
66+begin
67+ trymysqlForm1.ResultsMemo.Lines.Add (S)
68+end;
69+```
6670
6771连接按钮的事件程序于是就成为这样:
6872
69-`procedure TtrymysqlForm1.ConnectButtonClick(Sender: TObject);`\
70-`(* Connect to MySQL using user data from Text entry boxes on Main Form *)`\
71-`var strg: string;`\
72-`begin`\
73-` dummy1 :=  trymysqlForm1.HostEdit.text+#0;`\
74-` host := @dummy1[1];`\
75-` dummy2 := trymysqlForm1.UserEdit.text+#0;`\
76-` user := @dummy2[1] ;`\
77-` dummy3 := trymysqlForm1.PasswdEdit.text+#0;`\
78-` passwd := @dummy3[1] ;`\
79-` alloc := mysql_init(PMYSQL(@qmysql));`\
80-` sock :=  mysql_real_connect(alloc, host, user, passwd, database, 0, nil, 0);`\
81-` if sock=Nil then`\
82-`   begin`\
83-`     strg :='Couldn''t connect to MySQL.'; showstring (strg);`\
84-`     Strg :='Error was: '+ StrPas(mysql_error(@qmysql)); showstring (strg);`\
85-`  end`\
86-`   else`\
87-`   begin`\
88-`     trymysqlForm1.statusBar1.simpletext := 'Connected to MySQL';`\
89-`     strg := 'Now choosing database : ' + database; showstring (strg);`\
90-`{$ifdef Unix}`\
91-`     strg :='Mysql_port      : '+ IntToStr(mysql_port); showstring (strg);`\
92-`     strg :='Mysql_unix_port : ' + StrPas(mysql_unix_port); showstring (strg);`\
93-`{$endif}`\
94-`     Strg :='Host info       : ' + StrPas(mysql_get_host_info(sock));`\
95-`     showstring (strg);`\
96-`     Strg :='Server info     : ' + StrPas(mysql_stat(sock)); showstring (strg);`\
97-`     Strg :='Client info     : ' + Strpas(mysql_get_client_info);  showstring (strg);`\
98-` `\
99-`     trymysqlForm1.statusbar1.simpletext := 'Selecting Database ' + DataBase +'...';`\
100-` if mysql_select_db(sock,DataBase) < 0 then`\
101-` begin`\
102-`   strg :='Couldn''t select database '+ Database; ShowString (strg);`\
103-`   Strg := mysql_error(sock); ShowString (strg);`\
104-` end`\
105-` end;`\
106-`end;`
73+``` pascal
74+procedure TtrymysqlForm1.ConnectButtonClick(Sender: TObject);
75+(* Connect to MySQL using user data from Text entry boxes on Main Form *)
76+var strg: string;
77+begin
78+ dummy1 := trymysqlForm1.HostEdit.text+#0;
79+ host := @dummy1[1];
80+ dummy2 := trymysqlForm1.UserEdit.text+#0;
81+ user := @dummy2[1] ;
82+ dummy3 := trymysqlForm1.PasswdEdit.text+#0;
83+ passwd := @dummy3[1] ;
84+ alloc := mysql_init(PMYSQL(@qmysql));
85+ sock := mysql_real_connect(alloc, host, user, passwd, database, 0, nil, 0);
86+ if sock=Nil then
87+ begin
88+ strg :='Couldn''t connect to MySQL.'; showstring (strg);
89+ Strg :='Error was: '+ StrPas(mysql_error(@qmysql)); showstring (strg);
90+ end
91+ else
92+ begin
93+ trymysqlForm1.statusBar1.simpletext := 'Connected to MySQL';
94+ strg := 'Now choosing database : ' + database; showstring (strg);
95+{$ifdef Unix}
96+ strg :='Mysql_port : '+ IntToStr(mysql_port); showstring (strg);
97+ strg :='Mysql_unix_port : ' + StrPas(mysql_unix_port); showstring (strg);
98+{$endif}
99+ Strg :='Host info : ' + StrPas(mysql_get_host_info(sock));
100+ showstring (strg);
101+ Strg :='Server info : ' + StrPas(mysql_stat(sock)); showstring (strg);
102+ Strg :='Client info : ' + Strpas(mysql_get_client_info); showstring (strg);
103+
104+ trymysqlForm1.statusbar1.simpletext := 'Selecting Database ' + DataBase +'...';
105+ if mysql_select_db(sock,DataBase) < 0 then
106+ begin
107+ strg :='Couldn''t select database '+ Database; ShowString (strg);
108+ Strg := mysql_error(sock); ShowString (strg);
109+ end
110+ end;
111+end;
112+```
107113
108114右侧的文本框接下来输入一个SQL语句,末尾没有分号;当你对内容和语法满意时,按下SendQuery按钮,查询开始,结果将会写在ResultsMemo(结果)框内。
109115
110116The SendQuery event handler is again based on the FPC text-mode version, except that once again explicit type-conversion has to be done before strings are displayed in the box.
111117
112118A difference from the text-mode FPC program is that if an error condition is detected, the program does not halt and MySQL is not closed; instead, control is returned to the main form and an opportunity is given to correct the entry before the command is re-submitted. The application finally exits (with closure of MySQL) when the Exit Button is clicked.
113119
114120发送查询(SendQuery)的代码如下:
115121
116-`procedure TtrymysqlForm1.QueryButtonClick(Sender: TObject);`\
117-`var`\
118-` dumquery, strg: string;`\
119-`begin`\
120-`     dumquery := TrymysqlForm1.CommandEdit.text;`\
121-`     dumquery := dumquery+#0;`\
122-`     query := @dumquery[1];`\
123-`     trymysqlForm1.statusbar1.simpletext := 'Executing query : '+ dumQuery +'...';`\
124-`     strg := 'Executing query : ' + dumQuery; showstring (strg);`\
125-`     if (mysql_query(sock,Query) < 0) then`\
126-`     begin`\
127-`       Strg :='Query failed '+ StrPas(mysql_error(sock)); showstring (strg);`\
128-`     end`\
129-`     else`\
130-`     begin`\
131-`       recbuf := mysql_store_result(sock);`\
132-`       if RecBuf=Nil then`\
133-`       begin`\
134-`         Strg :='Query returned nil result.'; showstring (strg);`\
135-`       end`\
136-`       else`\
137-`       begin`\
138-`         strg :='Number of records returned  : ' + IntToStr(mysql_num_rows (recbuf));`\
139-`         Showstring (strg);`\
140-`         Strg :='Number of fields per record : ' + IntToStr(mysql_num_fields(recbuf));`\
141-`         showstring (strg);`\
142-`         rowbuf := mysql_fetch_row(recbuf);`\
143-`         while (rowbuf <>nil) do`\
144-`         begin`\
145-`              Strg :='(Id: '+ rowbuf[0]+', Name: ' + rowbuf[1]+ ', Email : ' +`\
146-`               rowbuf[2] +')';`\
147-`              showstring (strg);`\
148-`              rowbuf := mysql_fetch_row(recbuf);`\
149-`         end;`\
150-`       end;`\
151-`     end;`\
152-`end;`
122+``` pascal
123+procedure TtrymysqlForm1.QueryButtonClick(Sender: TObject);
124+var
125+ dumquery, strg: string;
126+begin
127+ dumquery := TrymysqlForm1.CommandEdit.text;
128+ dumquery := dumquery+#0;
129+ query := @dumquery[1];
130+ trymysqlForm1.statusbar1.simpletext := 'Executing query : '+ dumQuery +'...';
131+ strg := 'Executing query : ' + dumQuery; showstring (strg);
132+ if (mysql_query(sock,Query) < 0) then
133+ begin
134+ Strg :='Query failed '+ StrPas(mysql_error(sock)); showstring (strg);
135+ end
136+ else
137+ begin
138+ recbuf := mysql_store_result(sock);
139+ if RecBuf=Nil then
140+ begin
141+ Strg :='Query returned nil result.'; showstring (strg);
142+ end
143+ else
144+ begin
145+ strg :='Number of records returned : ' + IntToStr(mysql_num_rows (recbuf));
146+ Showstring (strg);
147+ Strg :='Number of fields per record : ' + IntToStr(mysql_num_fields(recbuf));
148+ showstring (strg);
149+ rowbuf := mysql_fetch_row(recbuf);
150+ while (rowbuf <>nil) do
151+ begin
152+ Strg :='(Id: '+ rowbuf[0]+', Name: ' + rowbuf[1]+ ', Email : ' +
153+ rowbuf[2] +')';
154+ showstring (strg);
155+ rowbuf := mysql_fetch_row(recbuf);
156+ end;
157+ end;
158+ end;
159+end;
160+```
153161
154162保存你的项目(Project),并且执行:运行-》运行。
155163
156164- 下载 MYSQL 示例源代码
157165
158166一份完整的程序清单可以从这里获得: [Sample Source Code](http://lazarus-ccr.sourceforge.net/kbdata/mysqldemo.tar.gz)
159167
160168### 使用TMySQL50Connection控件连接
161169
162170英文版写的过多,不会翻译,自己写了个代码,不过英文版写的很详细,有兴趣或者会翻译的可以重新编辑一下本段。
163171
164172各个控件的连接方式:
165173
166174一、TMySQL50Connection;
167175
168176二、TSQLTransaction并且Database属性为TMySQL50Connection;
169177
170178三、TSQLQuery且Database属性为TMySQL50Connection、Transaction属性为TSQLTransaction;
171179
172180四、TDatasource的DataSet属性TSQLQuery;
173181
174182五、TDBGrid的Datasource属性为TDatasource
175183
176184 procedure TfrmMain.btnMYSQLClick(Sender: TObject);
177185 begin
178186 try
179187 //conn_mysql5是TMySQL50Connection
180188 conn_mysql5.HostName := '127.0.0.1';//主机
181189 conn_mysql5.UserName := 'root';//登录名
182190 conn_mysql5.Password := '123';//密码
183191 conn_mysql5.CharSet := 'utf8';//如果在MYSQL中建表设置了UTF8,此处也设置,中文显示是正常的
184192 conn_mysql5.DatabaseName := 'test'; //MYSQL的数据库
185193 conn_mysql5.Open;
186194 except
187195 on E: Exception do
188196 begin
189197 ShowMessage('连接出错:' + E.Message);
190198 Exit;
191199 end;
192200 end;
193201 //打开一个表
194202 SQLQuery1.Close;
195203 SQLQuery1.SQL.Text := 'select * from t1';
196204 try
197205 SQLQuery1.Open;
198206 except
199207 on E: Exception do
200208 begin
201209 ShowMessage('打开表出错:' + E.Message);
202210 Exit;
203211 end;
204212 end;
205213 end;
206214
207215## Lazarus 和 PostgreSQL
208216
209217这是一个很简短的教程,针对Lazarus 0.9.12及以后版本,连接到PostgreSQL数据库,本地或远程,使用TPQConnection组件。
210218
211219After correct install, follow these steps:
212220
213221- Place a PQConnection from the SQLdb tab
214222- Place a SQLQuery from the SQLdb tab
215223- Place a SQLTransaction from the SQLdb tab
216224- Place a DataSource from the DataAccess tab
217225- Place a DBGrid from the DataControls tab
218226
219227- In the PQConnection fill in:
220228 - transaction property with the respective SQLTransaction object
221229 - Database name
222230 - HostName
223231 - UserName + password
224232
225233- Check that the SQLTransaction was automatically changed to point to the PQConnection
226234
227235- In the SQLQuery fill in:
228236 - transaction property with the respective object
229237 - database property with respective object
230238 - SQL (something like 'select * from anytable')
231239
232240- In the DataSource object fill in the DataSet property with the SQLQuery object
233241
234242- In the DBGrid fill in the datasource as the DataSource Object
235243
236244Turn everything to connected and active and the DBGrid should be filled in design time. TDBText and TDBEdit seem to work but (for me) they only _show_ _data_.
237245
238246To change contents in the database, I called the DB Engine direct with the following code:
239247
240-` try`\
241-`   sql:= 'UPDATE table SET setting=1';`\
242-`   PQDataBase.Connected:=True;`\
243-`   PQDataBase.ExecuteDirect('Begin Work;');`\
244-`   PQDataBase.ExecuteDirect(sql);`\
245-`   PQDataBase.ExecuteDirect('Commit Work;');`\
246-`   PQDataBase.Connected:=False;`\
247-` except`\
248-`   on E : EDatabaseError do`\
249-`     MemoLog.Append('DB ERROR:'+sql+chr(13)+chr(10)+E.ClassName+chr(13)+chr(10)+E.Message);`\
250-`   on E : Exception do`\
251-`     MemoLog.Append('ERROR:'+sql+chr(13)+chr(10)+E.ClassName+chr(13)+chr(10)+E.Message);`\
252-` end;`
248+``` pascal
249+ try
250+ sql:= 'UPDATE table SET setting=1';
251+ PQDataBase.Connected:=True;
252+ PQDataBase.ExecuteDirect('Begin Work;');
253+ PQDataBase.ExecuteDirect(sql);
254+ PQDataBase.ExecuteDirect('Commit Work;');
255+ PQDataBase.Connected:=False;
256+ except
257+ on E : EDatabaseError do
258+ MemoLog.Append('DB ERROR:'+sql+chr(13)+chr(10)+E.ClassName+chr(13)+chr(10)+E.Message);
259+ on E : Exception do
260+ MemoLog.Append('ERROR:'+sql+chr(13)+chr(10)+E.ClassName+chr(13)+chr(10)+E.Message);
261+ end;
262+```
253263
254264- 备注:
255265 - Tested on windows, Lazarus 0.9.12 + PgSQL 8.3.1
256266 - Some tests in linux, Lazarus 0.9.12 and PgSQL 8.0.x
257267
258268- Instalation and errors:
259269 - In the tested version of Lazarus .12, fields of type "text" and "numeric" have bugs
260270 - I used with no problems char fixed size, int and float8
261271 - Sometimes restarting Lazarus solves stupid errors...
262272 - After some errors, the transactions remain active and should be deactivated mannually
263273 - Changes made in Lazarus are of course not visible until transaction commited
264274 - The integrated debugger seems buggy (at least in windows) - sometimes running outside of the IDE may help to find errors
265275 - In linux certain error messages are printed in the console -- run your program in the command line, sometimes there is some extra useful debugging info
266276 - Error: "Can not load Postgresql client. Is it installed (libpq.so) ?"
267277 - Add the path to seach libpq* from the PostgreSQL installation.
268278 - In linux add the path to the libpq.so file to the libraries section in your /etc/fpc.cfg file. For example : -Fl/usr/local/pgsql/lib
269279 - In windows, add these libs anywhere in the Path environment variable or project dir
270280 - I windows, I copied all the DLLs in my C:\Program Files\PostgreSQL\8.1\bin dir to another dir in the PATH
271281 - Or add this postgres\bin dir to the path
272282
273283## Lazarus and SQLite
274284
275285by Luiz Américo
276286
277287Visit the [sqlite4fpc homepage](http://www.geocities.com/camara_luiz/) to find the API reference and more tutorials.
278288
279289### Introduction
280290
281291TSqliteDataset and TSqlite3Dataset are TDataset descendants that access, respectively, 2.8.x and 3.x.x sqlite databases. Below is a list of the principal advantages and disadvantages:
282292
283293Advantages:
284294
285295- Flexible: programmers can choose to use or not to use the SQL language, allowing them to work with simple table layouts or any complex layout that SQL/sqlite allows
286296- Automatic database update: no need to update the database manually with SQL statements, a single method take cares of it
287297- Fast: it caches the data in memory, making browsing in the dataset fast
288298- No server installation/configuration: just ship together with sqlite dynamic library
289299
290300Disadvantages
291301
292302- Requires external file (sqlite library)
293303
294304### Requirements
295305
296306- For sqlite2 databases:
297307 - fpc 2.0.0
298308 - Lazarus 0.9.10
299309 - sqlite runtime library 2.8.15 or above (get from www.sqlite.org)
300310
301311- For sqlite3 databases:
302312 - fpc 2.0.2
303313 - Lazarus 0.9.11 (svn revision 8443 or above)
304314 - sqlite runtime library 3.2.1 or above (get from www.sqlite.org)
305315
306316**Before initiating a lazarus projects, ensure that:**
307317
308318- the sqlite library is on the system PATH or in the executable directory
309319- under Linux, put cmem as the first unit in uses clause of the main program
310320
311321### How To Use (Basic Usage)
312322
313323Install the package found at /components/sqlite directory (see instructions [[Install Packages|here]])
314324
315325At design time set the following properties:
316326
317327- FileName: path of the sqlite file \[required\]
318328- TableName: name of the table used in the sql statement \[required\]
319329- Sql: a SQL select statement \[optional\]
320330
321331**Creating a Table (Dataset)**
322332
323333Double click in the component icon or use the 'Create Table' item of the popup menu that appears when clicking the right mouse button. A simple self-explaining table editor will be show.
324334
325-` Here is all field types supported by TSqliteDataset and TSqlite3Dataset: `\
326-` `\
327-` Integer`\
328-` AutoInc`\
329-` String`\
330-` Memo`\
331-` Bool `\
332-` Float`\
333-` Word`\
334-` DateTime`\
335-` Date`\
336-` Time`\
337-` LargeInt`\
338-` Currency`\
339-` `
335+```text
336+ Here is all field types supported by TSqliteDataset and TSqlite3Dataset:
337+
338+ Integer
339+ AutoInc
340+ String
341+ Memo
342+ Bool
343+ Float
344+ Word
345+ DateTime
346+ Date
347+ Time
348+ LargeInt
349+ Currency
350+```
340351
341352**Retrieving the data**
342353
343354After creating the table or with a previously created Table, open the dataset with Open method. If the SQL property was not set then all records from all fields will be retrieved, the same if you set the SQL to:
344355
345-` SQL:='Select * from TABLENAME'; `
356+``` pascal
357+ SQL:='Select * from TABLENAME';
358+```
346359
347360**Applying changes to the underlying datafile**
348361
349362To use the ApplyUpdates function, the dataset must contain at least one field that fills the requirements for a Primary Key (values must be UNIQUE and not NULL)
350363
351364It's possible to do that in two ways:
352365
353366- Set PrimaryKey property to the name of a Primary Key field
354367- Add an AutoInc field (This is easier since the TSqliteDataSet automatically handles it as a Primary Key)
355368
356369If one of the two conditions is set then just call
357370
358-` ApplyUpdates;`
371+```text
372+ ApplyUpdates;
373+```
359374
360375PS1: If both conditions are set, the field corresponding to PrimaryKey is used to apply the updates.
361376
362377PS2: Setting PrimaryKey to a field that is not a Primary Key will lead to loss of data if ApplyUpdates is called, so ensure that the chosen field contains not Null and Unique values before using it.
363378
364379### Remarks
365380
366381- Although it has been tested with 10000 records and worked fine, TSqliteDataset keeps all the data in memory, so remember to retrieve only the necessary data (principally with Memo Fields).
367382- The same datafile (Filename property) can host several tables/datasets
368383- Several datasets (different combinations of fields) can be created using the same table simultaneously
369384- It's possible to filter the data using WHERE statements in the sql, closing and reopening the dataset (or calling RefetchData method). But in this case, the order and number of fields must remain the same
370385- It's also possible to use complex SQL statements using aliases, joins, views in multiple tables (remember that they must reside in the same datafile), but in this case ApplyUpdates won't work. If someone wants to use complex queries and to apply the updates to the datafile, mail me and I will give some hints how to do that
371386- Setting filename to a sqlite2.x datafile not created by TSqliteDataset and opening it is allowed but some fields won't have the correct field type detected. These will be treated as string fields.
372387
373388Generic examples can be found at fpc/fcl/db/sqlite CVS directory
374389
375390Luiz Américo pascalive(at)bol(dot)com(dot)br
376391
377392## Lazarus and MSSQL
378393
379394It is working with Zeoslib (latest cvs), see the links on bottom of page.
380395
381396## Lazarus and Interbase / Firebird
382397
383398See [[Install Packages]]. On this page is a first small example en explanation about how to connect to an IB or FB server.
384399
385400Also work with the latest Zeoslib (from cvs).
386401
387402### FBLib Firebird Library
388403
389404[1](http://fblib.altervista.org/%7CFBLib) is an open Source Library No Data Aware for direct access to Firebird Relational Database from Borland Delphi / Kylix, Freepascal and Lazarus.
390405
391406Current Features include:
392407
393408- Direct Access to Firebird 1.0.x 1.5.x Classic or SuperServer
394409- Multiplatform \[Win32,Gnu/Linux,FreeBSD)
395410- Automatic select client library 'fbclient' or 'gds32'
396411- Query with params
397412- Support SQL Dialect 1/3
398413- LGPL License agreement
399414- Extract Metadata
400415- Simple Script Parser
401416- Only 100-150 KB added into final EXE
402417- Support BLOB Fields
403418- Export Data to HTML SQL Script
404419- Service manager (backup,restore,gfix...)
405420- Events Alerter
406421
407422You can download documentation on [FBLib's website](http://fblib.altervista.org/).
408423
409424## Lazarus 和 dBase
410425
411426Tony Maro: You might also want to visit the beginnings of the [[Lazarus Tdbf Tutorial|TDbf Tutorial page]] (译注:略,建议另开新页)
412427
413428## Related Links
414429
415430- [[Databases|Creating Databases Applications with Lazarus using the DB-unit]]\
416431- [[MySQLDatabases|Creating a database application using MySQL]]\
417432- [[Zeos tutorial|Creating a database application using the Zeos components]]
418433- [Pascal Data Objects](http://pdo.sourceforge.net) is a database API that worked for both FPC and Delphi and utilises native MySQL libraries for version 4.1 and 5.0 and Firebird SQL 1.5, and 2.0. It's inspired by PHP's PDO class.
419434
420435## Contributors and Changes
421436
422437This page has been converted from the epikwiki [version](http://lazarus-ccr.sourceforge.net/index.php?wiki=LazarusDatabase).
423438
424439---
425440*From the Free Pascal wiki, page "Lazarus Database Tutorial/zh CN", as it stood on 2011-10-03 after a change by Lioncn, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
426441Category: zh

Back to history