|
|
|
Samples
|
|
|
|
The following example
will show all available tables
in a listbox. Put a
listbox, a button and a
TASQLiteDatabase component on
your form. Setup the correct
database. Add the below code
to the onclick event of your
button:
|
|
procedure
TForm1.Button1Click(Sender:
TObject); begin DB.GetTableNames(ListBox1.Items,
true); end;
|
|
|
The following example
will create a full data-aware
tablegrid on your form. Create
a new application, put a TASQLiteDatabase
and a TASQLiteTable component
on your form. Apply the correct
database to the database component.
Apply the TASQLiteDatabase component
on the TASQLiteTable. Select
the table to create the grid
for. Add a TDataSource component,
a TDBGrid and a TDBNavigator
component on your form. Connect
these components to eachother
in the useual way (TTable to
TDataSource, TDBGrid to TDataSource
and TDBNavigator to TDatasource).
Set the Active property to 'true'
|
|
no
code is necessary.
|
|
|
The following example
will create a full data-aware
tablegrid on your form where
the user can enter the tablename.
Create a new application,
put a TASQLiteDatabase and a
TASQLiteTable component on your
form. Apply the correct database
to the database component. Apply
the TASQLiteDatabase component
on the TASQLiteTable. Add a
TDataSource component, a TDBGrid
and a TDBNavigator component
on your form. Connect these
components to eachother in the
useual way (TTable to TDataSource,
TDBGrid to TDataSource and TDBNavigator
to TDatasource). Put an edit
field for the tablename on your
form (with the first example
you can also use a pulldown
list). Put a button to start
the dialog on the form and apply
the next code to the onclick
event of the button.
|
|
procedure
TForm1.Button1Click(Sender:
TObject); begin ASQLiteTable1.TableName
:= 'MyTable'; ASQLiteTable1.Open end;
|
|
|
The following example
will select data from a table
using parameters, obtained from
a form Create a new application,
put a TASQLiteDatabase and a
TASQLiteQuery component on your
form. Suppose you want to select
a name from the edit field then
you should put an edit field
on your form. Apply the correct
database to the database component.
Apply the TASQDatabase component
on the TASQTable. Add a TDataSource
component and a TDBGrid
component on your form. Connect
these components to eachother
in the useual way (TTable to
TDataSource, TDBGrid to TDataSource).
Put an edit field for the search
criteria on your form. Put a
button to start the dialog on
the form and apply the next
code to the onclick event of
the button.
|
|
procedure
TForm1.Button1Click(Sender:
TObject); begin with
ASQLiteQuery1 do begin close;
SQL.Clear;
SQL.Add('select
* from mytable where name like
%:name'); Params[0].AsString
:= Edit1.Text Open;
end; end;
|
|
|
|
|