Difference between revisions of "TSQLite3Connection/ja"

From Lazarus wiki
Jump to navigationJump to search
(Created page with "{{TSQLite3Connection/ja}} {{Infobox databases/ja}} {{Note|Instead of using a TMySQLite3Connection a proxy-like TSQLConnector may be used to create more generic database a...")
 
Line 1: Line 1:
 
{{TSQLite3Connection/ja}}
 
{{TSQLite3Connection/ja}}
{{Infobox databases/ja}}
+
{{Infobox databases}}
  
{{Note|Instead of using a TMySQLite3Connection a proxy-like [[TSQLConnector]] may be used to create more generic database applications}}'''TSQLite3Connection''' [[image:tsqlite3connection.png]] is the database connection component for use [[SQLite]]. The component is found on [[SQLdb tab]] of the [[Component Palette]].
+
{{| TSQLite3Connection を使う代わりに、プロキシライクな [[TSQLConnector]] によって、より一般的なデータベースアプリケーションを作ることができます。}}'''TSQLite3Connection''' [[image:tsqlite3connection.png]] [[SQLite]]を使うためのデータベース接続コンポーネントです。これらのコンポーネントは、[[Component Palette]] [[SQLdb tab]] にあります。
  
TSQLite3connection is a FCL (not 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.
Line 22: Line 22:
 
     Connect.Transaction := Trans;
 
     Connect.Transaction := Trans;
 
     Connect.DatabaseName := 'test_dbase';
 
     Connect.DatabaseName := 'test_dbase';
     Trans.StartTransaction;  // opens Connect, EInOutError if SQLite not installed
+
     Trans.StartTransaction;  // データベースへの接続を行います。SQLite をインストールしていない場合、EInOutError が起きます。(訳注;Lazarus と SQLite の 32bit、64bit を合わせないとエラーが起きます)
     Connect.ExecuteDirect('create table TBLNAMES (ID integer Primary Key, NAME varchar(40));');
+
     Connect.ExecuteDirect('create table TBLNAMES (ID integer Primary Key, NAME varchar(40));'); // 訳注;2度目の実行時には、ここで「TBLNAMESのテーブルは作成済み」というエラーメッセージが表示されると思います。
 
     Trans.Commit;
 
     Trans.Commit;
 
     Trans.Free;
 
     Trans.Free;
Line 38: Line 38:
 
* [[SQLite/ja]]
 
* [[SQLite/ja]]
  
{{LCL Components}}
+
{{LCL Components/ja}}

Revision as of 07:54, 2 March 2018

English (en) français (fr) 日本語 (ja) polski (pl)

Databases portal

References:

Tutorials/practical articles:

Databases

Advantage - MySQL - MSSQL - Postgres - Interbase - Firebird - Oracle - ODBC - Paradox - SQLite - dBASE - MS Access - Zeos

Template:注TSQLite3Connection tsqlite3connection.pngSQLiteを使うためのデータベース接続コンポーネントです。これらのコンポーネントは、Component PaletteSQLdb tab にあります。

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.

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 が起きます。(訳注;Lazarus と SQLite の 32bit、64bit を合わせないとエラーが起きます)
    Connect.ExecuteDirect('create table TBLNAMES (ID integer Primary Key, NAME varchar(40));'); // 訳注;2度目の実行時には、ここで「TBLNAMESのテーブルは作成済み」というエラーメッセージが表示されると思います。
    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

Template:LCL Components/ja