Difference between revisions of "TSQLite3Connection/ja"
Miyatakejiro (talk | contribs) |
Miyatakejiro (talk | contribs) |
||
Line 2: | Line 2: | ||
{{Infobox databases}} | {{Infobox databases}} | ||
− | {{Note| TSQLite3Connection を使う代わりに、プロキシライクな [[TSQLConnector]] によって、より一般的なデータベースアプリケーションを作ることができます。}}'''TSQLite3Connection''' [[image:tsqlite3connection.png]] は [[SQLite]]を使うためのデータベース接続コンポーネントです。これらのコンポーネントは、[[Component Palette]] の [[SQLdb tab]] にあります。 | + | {{Note| TSQLite3Connection を使う代わりに、プロキシライクな [[TSQLConnector/ja]] によって、より一般的なデータベースアプリケーションを作ることができます。}}'''TSQLite3Connection''' [[image:tsqlite3connection.png]] は [[SQLite/ja]]を使うためのデータベース接続コンポーネントです。これらのコンポーネントは、[[Component Palette/ja]] の [[SQLdb tab/ja]] にあります。 |
TSQLite3connection は FCL (LCLではなく) の non visual component meaning that it can be used in (eg) ObjectPascal, console applications as well as Lazarus GUI ones. Unfortunately there are no FCL docs for TSQLite3Connection but its interface is similar to its parent ( [[TSQLConnection]] ). As SQLite is an embedded or non-server | TSQLite3connection は FCL (LCLではなく) の non visual component meaning that it can be used in (eg) ObjectPascal, console applications as well as Lazarus GUI ones. Unfortunately there are no FCL docs for TSQLite3Connection but its interface is similar to its parent ( [[TSQLConnection]] ). As SQLite is an embedded or non-server | ||
database, its use may not require setting .host, .username nor .password. An example of how its used in an ObjectPascal programme is below, when used in | database, its use may not require setting .host, .username nor .password. An example of how its used in an ObjectPascal programme is below, when used in | ||
Lazarus, similar setting can be made using the Object Inspector. | Lazarus, similar setting can be made using the Object Inspector. | ||
+ | |||
+ | (訳注;以下を実行する前に、SQLite をインストールする必要がありますが、その際に、Lazarus と同じcpu向け(つまり、32bit(x86)か64bit用か) のSQLiteを用いないとエラーが起きます) | ||
+ | (訳注;2度目の実行時には、「TBLNAMESのテーブルは作成済み」というエラーメッセージが表示されると思います。) | ||
<syntaxhighlight> | <syntaxhighlight> | ||
Line 22: | Line 25: | ||
Connect.Transaction := Trans; | Connect.Transaction := Trans; | ||
Connect.DatabaseName := 'test_dbase'; | Connect.DatabaseName := 'test_dbase'; | ||
− | Trans.StartTransaction; // データベースへの接続を行います。SQLite をインストールしていない場合、EInOutError | + | Trans.StartTransaction; // データベースへの接続を行います。SQLite をインストールしていない場合、EInOutError が起きます。 |
− | Connect.ExecuteDirect('create table TBLNAMES (ID integer Primary Key, NAME varchar(40));'); | + | Connect.ExecuteDirect('create table TBLNAMES (ID integer Primary Key, NAME varchar(40));'); |
Trans.Commit; | Trans.Commit; | ||
Trans.Free; | Trans.Free; |
Revision as of 08:59, 2 March 2018
│
English (en) │
español (es) │
français (fr) │
日本語 (ja) │
polski (pl) │
References:
Tutorials/practical articles:
Databases |
TSQLite3Connection は SQLite/jaを使うためのデータベース接続コンポーネントです。これらのコンポーネントは、Component Palette/ja の SQLdb tab/ja にあります。
TSQLite3connection は FCL (LCLではなく) の non visual component meaning that it can be used in (eg) ObjectPascal, console applications as well as Lazarus GUI ones. Unfortunately there are no FCL docs for TSQLite3Connection but its interface is similar to its parent ( TSQLConnection ). As SQLite is an embedded or non-server database, its use may not require setting .host, .username nor .password. An example of how its used in an ObjectPascal programme is below, when used in Lazarus, similar setting can be made using the Object Inspector.
(訳注;以下を実行する前に、SQLite をインストールする必要がありますが、その際に、Lazarus と同じcpu向け(つまり、32bit(x86)か64bit用か) のSQLiteを用いないとエラーが起きます) (訳注;2度目の実行時には、「TBLNAMESのテーブルは作成済み」というエラーメッセージが表示されると思います。)
program BasicDBase;
{$mode objfpc} {$ifdef mswindows}{$apptype console}{$endif}
uses
sqldb, sqlite3conn;
var
Connect : TSQLite3Connection;
Trans : TSQLTransaction;
begin
Connect := TSQLite3Connection.Create(nil);
Trans := TSQLTransaction.Create(Connect);
Connect.Transaction := Trans;
Connect.DatabaseName := 'test_dbase';
Trans.StartTransaction; // データベースへの接続を行います。SQLite をインストールしていない場合、EInOutError が起きます。
Connect.ExecuteDirect('create table TBLNAMES (ID integer Primary Key, NAME varchar(40));');
Trans.Commit;
Trans.Free;
Connect.Free;
end.
The ExecuteDirect() procedure is a fairly limited means to call SQL, in a real ap, you will need something like TSQLQuery. Note also the above demo does not do
any error checking.
See also