Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
3 errors with FIreDAC
#1
Dear, use delphi 11.2.1 and IW 15.2.69

1.- FireDAC doesn't work with a data module in IW, only if I put the components in the IWUserSession or in the IWForms it works fine.


2.- I have a mandatory required field (required=true in IW). When deleting a record (FDQuery.delete) a message appears asking you to enter the required field.


3.- I have a non-null field from a SQL Server database (required=false in IW so that it doesn't give me problems). When deleting the record I get an error message that you need to enter the required field.

The only way to solve this is by setting required=False and in the database that the field allows entering null values.

I don't know if this only happens to me but since I don't have time to find out and the IntraWeb documentation is so bad, it can't work with FireDAC or it simply can't work with IntraWeb
Reply
#2
Hi,

Do you create a separate datamodule? You should not do that.

All FD components should be in UserSession form. A unique UserSession is created for each user.

unit UserSessionUnit;

{
  This is a DataModule where you can add components or declare fields that are specific to
  ONE user. Instead of creating global variables, it is better to use this datamodule. You can then
  access it using UserSession.
}
Reply
#3
Thanks for answering. In the old intraweb documentation (the only one there is from 20 years ago), the examples I use, forum readings, and people using IW all indicate that a data module can be used. There is no documentation that says that FireDAC cannot be used with a data module. Thank you
Reply
#4
(03-16-2023, 02:17 PM)raulevm Wrote: Thanks for answering. In the old intraweb documentation (the only one there is from 20 years ago), the examples I use, forum readings, and people using IW all indicate that a data module can be used. There is no documentation that says that FireDAC cannot be used with a data module. Thank you

A datamodule can be used, you just need to create the datamodule within the UserSession module.   This makes it a part of the session.

Dan
Reply
#5
(03-18-2023, 03:35 AM)DanBarclay Wrote:
(03-16-2023, 02:17 PM)raulevm Wrote: Thanks for answering. In the old intraweb documentation (the only one there is from 20 years ago), the examples I use, forum readings, and people using IW all indicate that a data module can be used. There is no documentation that says that FireDAC cannot be used with a data module. Thank you

A datamodule can be used, you just need to create the datamodule within the UserSession module.   This makes it a part of the session.

Dan

Please explain why you want an extra Datamodule.
Reply
#6
(03-18-2023, 12:52 PM)Mikael Nilsson Wrote:
(03-18-2023, 03:35 AM)DanBarclay Wrote:
(03-16-2023, 02:17 PM)raulevm Wrote: Thanks for answering. In the old intraweb documentation (the only one there is from 20 years ago), the examples I use, forum readings, and people using IW all indicate that a data module can be used. There is no documentation that says that FireDAC cannot be used with a data module. Thank you

A datamodule can be used, you just need to create the datamodule within the UserSession module.   This makes it a part of the session.

Dan

Please explain why you want an extra Datamodule.
UserSession (TUserSession) is a very special data module.  You get to determine the contents of it, and it is available per session at runtime.  That is, each session has its own copy of UserSession.   IW completely manages the creation/destruction/visibility of UserSession.   You can create your own data module, then make it a part of UserSession like:


Code:
Type
   public
      MyDataMod: TMyDataMod;


procedure TUserSession.DataModuleCreate(Sender:TObject);
begin
   myDataMod:=TMyDataMod.Create(nil);
end;
procedure TUserSession.DataModuleDestroy(Sender:TObject);
begin
   freeandnil(myDataMod);
end;

Doing that makes your datamodule available, but a part of UserSession.

    UserSession.myDataMod....

I'm not sure of Firedac requirements, you may be able to share a common connection but I suspect including the connection (per session) in the data module would be more robust.   THere are a number of demos online with data connections and I believe they may be using datamodules.

Dan
Reply
#7
I responded via email, but here it goes:

1) When the user gets a timeout. Intraweb shows a error 500. (works perfectly in SA)

Please check the item 8 in this document: https://docs.atozed.com/Docs.dll/deployment/isapi/Deploying%20ISAPI%20using%20IIS.html

From that document:



Quote:When deploying ISAPI applications in Windows servers and a time-out error occurs, you will probably get an error page like this:
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
This happens because IIS replaces any content with HTTP status code bigger than 400 with its own content (a useless error message, by the way). When the timeout error occurs, IntraWeb answers with an error code 500. There is no easy - if any - way to programmatically change this behavior from within an ISAPI extension. You need to create (or edit) a web.config file for your application, like this:
<?xml version="1.0" encoding="UTF-8"?>
  <configuration>
      <system.webServer>
        <handlers accessPolicy="Read, Execute, Script" />
        <httpErrors existingResponse="PassThrough" />
      </system.webServer>
  </configuration>
Then save this file in the same folder where your ISAPI DLL is located and you are done.


2) I have tried to build a 64bit version of my application. But it only shows a white webpage instead of Login page.

Does this work when building as SA? Is this specific when you deploy to IIS? 

IntraWeb has no issues when building as 64 bits.

If this is specific to IIS, it may be related to the configuration of the application pool when deploying it. That same document above has detailed information on how to deploy it to IIS. If not, can you please try a simple test case application built from scratch using the IntraWeb application wizard? Put a single TIWButton on it and build it as 64 bits. See how it behaves.


3) I always used the UserSession for my database components (FireDac). Is this not correct?

There is nothing wrong in putting your FireDac Database components in the UserSession. What we recommend is not putting *everything* related to the data access (i.e. all queries and other datasets) in the same place (or the UserSession). It makes things harder to maintain and also the memory consumption is higher (because every component instance is "alive" all the time). On the other hand, splitting the components into DataModules makes things more manageable and if you create and destroy them as needed, you make your application lighter (i.e. it will use less memory). Of course this needs to be considered on a case-by-case basis.

These two demos show the concept of using DataMoudules to organize the data access components (queries, etc). Please have in mind that not everything in these demos is a rigid recipe to  create IW DB applications. But they show some concepts that can be useful to your application. 

https://github.com/Atozed/IntraWeb/tree/master/15/Delphi/Database/IWADODBDemo

https://github.com/Atozed/IntraWeb/tree/master/XIV/Delphi/Database/IWADOPool/source
Reply
#8
Thanks for the help, I was able to fix the problem by following this help url:

https://docs.atozed.com/docs.dll/getting...rview.html

I have changed my connection component structure to include only the FDConnection in the UserSession, and the other FDQuery components in the other data modules. In each data module I reference the ServerController to assign the connection property of each FDQuery at runtime, using the UserSession variable:




Code:
FDQuery1.Connection := UserSession.FDConnection1;


And in each IWForm I assign the DataSet:

Code:
implementation

{$R *.dfm}

uses ServerController;


procedure TIWForm1.IWAppFormCreate(Sender: TObject);
begin
DataSource1.DataSet := UserSession.DM.FDQuery1;
UserSession.DM.FDQuery1.Open;
end;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)