Use Intraweb (44)-Test read SqLite (three)

Source: Internet
Author: User
Tags connection pooling sqlite



Use data connection pooling (Tiwdatamodulepool).
When creating a new project, check the Pool Data Connections:

The new Pool (Tiwdatamodulepool) is placed on the Servercontroller form (which is also a data module) and needs to know the change is that it adds two functions:
function LockDataModule: TDataModule1;
procedure UnlockDataModule(ADataModule: TDataModule1);

At the same time, the Wizard also automatically generated a special data module datamoduleunit;
Place the data source related controls on the Datamoduleunit form first:
FDPhysSQLiteDriverLink1: TFDPhysSQLiteDriverLink;
FDGUIxWaitCursor1: TFDGUIxWaitCursor;
FDConnection1: TFDConnection;
DataSource1: TDataSource;
FDTable1: TFDTable;

Then write the code in its OnCreate event:
procedure TDataModule1.DataModuleCreate (Sender: TObject);
begin
   FDTable1.Connection: = FDConnection1;
   DataSource1.DataSet: = FDTable1;

   FDConnection1.DriverName: = ‘SQLite’;
   FDConnection1.Params.Add (‘Database = FDDemo.sdb’); // Don't forget to copy FDDemo.sdb to the program directory

   FDTable1.TableName: = ‘Orders’;
// FDTable1.Active: = True;
end;

Finally, return to the main form, first put a iwdbgrid1:tiwdbgrid; Then write the code:
uses DataModuleUnit, ServerController;

procedure TIWForm1.IWAppFormCreate(Sender: TObject);
var
  fDataModule: TDataModule1;
begin
  fDataModule := LockDataModule;
  IWDBGrid1.DataSource := fDataModule.DataSource1;
  fDataModule.FDTable1.Active := True;
  UnlockDataModule(fDataModule);

  IWDBGrid1.Align := alClient;
end;

:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.