Recent

Author Topic: EStreamError Was: DataModule shows data at design time but not run time  (Read 731 times)

HomerJ

  • New Member
  • *
  • Posts: 13
I'm brand new to Lazarus/FPC, and am trying to port a Delphi 2007 app to Lazarus/FPC. It has a Firebird database and the DB, Lazarus, and the project app are in Windows 8.1.  I have been programming with Delphi since D1, but I have discovered that Lazarus is NOT a clone of Delphi, so I'm asking newbie questions.

The following data access controls are on a DataModule.
    IBConnection1: TIBConnection;
    rsClients: TSQLQuery;
    dsClients: TDataSource;
    SQLTransaction1: TSQLTransaction;

After adding the "create" code in the .LPR , I get this message, and have not been able to fix it:

Project ABS_Customers raised exception class 'EStreamError' with message:
Failed to initialize component class "TDM": No streaming method available.


My Code


program Customer_Tracking;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Interfaces, // this includes the LCL widgetset
  Forms, datetimectrls, DataModule1, frmmainU;

{$R *.res}

begin
  RequireDerivedFormResource:=True;
  Application.Scaled:=True;
  Application.Initialize;
  Application.CreateForm(TDM, DM);
  Application.CreateForm(TfrmMain, frmMain);
  Application.Run;
end.
« Last Edit: July 03, 2019, 09:01:26 am by HomerJ »

mangakissa

  • Hero Member
  • *****
  • Posts: 941
If you create a new datamodule, the line to create this form will be put in the source automatically.

Start a new project and create a datamodule. What is the source file telling you. it should be:
Code: Pascal  [Select]
  1. begin
  2.   RequireDerivedFormResource:=True;
  3.   Application.Scaled:=True;
  4.   Application.Initialize;
  5.   Application.CreateForm(TForm1, Form1);
  6.   Application.CreateForm(TDataModule1, DataModule1);
  7.   Application.Run;
  8. end.
  9.  
I have nothing done in the source file.
Lazarus 1.84 (32b) / FPC 3.0.4
Windows 10

HomerJ

  • New Member
  • *
  • Posts: 13
Thank you for the example. The only difference I see between your sample and mine is the order in which the two forms are created. I changed my code to match your order. Now the only difference is in the naming of my DataModule. I still get the same error.  I will try your suggestion, and remove my existing DataModule so I can create one from scratch. Just to be safe, I will not copy the data access objects, I will create new ones. I'll let you know how that works. Thanks again.

devEric69

  • Full Member
  • ***
  • Posts: 138
A tip: if you use InterBase or FireBird, then you should really consider to install and use the IBX package (from "Package > Online package manager"), and then, using only the components of this suite (TIBDataset and its descendants, TIBTransaction, and also the IBX visual components).
My 2 cents.
use: Ubuntu 18.04 + Laz. 1.8.5 + FPC 3.0.5 (64 bits).

dsiders

  • Full Member
  • ***
  • Posts: 220
A tip: if you use InterBase or FireBird, then you should really consider to install and use the IBX package (from "Package > Online package manager"), and then, using only the components of this suite (TIBDataset and its descendants, TIBTransaction, and also the IBX visual components).
My 2 cents.

+2 cents.

And if you want the latest bug fixes, get the code from the MWA version control server: https://svn.mwasoftware.co.uk/viewvc/public/ibx/trunk/.
Lazarus 2.0.4 / FPC 3.0.4 / Windows 8.1 64-bit

HomerJ

  • New Member
  • *
  • Posts: 13
Thanks for the tips about IBX and the latest bug fixes. Both good ideas. I have to admit, Delphi has spoiled me for what I see so far. Much easier to get stuff done, but then I have years of experience with Delphi, and I'm just learning Lazarus/FPC. Native Delphi controls for Firebird really suck compared to IBDac, so I'm sure IBX will make a big difference.

I've been momentarily pulled away from this project so I may not be back for a day or so. I'm very interested in making this work because this project would be best as a cross platform app.  Thanks again.

HomerJ

  • New Member
  • *
  • Posts: 13
I seem to have solved the problem by copying all the Data Access controls from the original DataModule,  deleting all references to the original DataModule, Deleting the DataModule files from the source directory, creating a new one and pasting all the Data Access controls into the new DM. Naturally, I had to relink all the Data Controls (edits, combo boxes, etc).  What an excessive way to do this.  I am worried about creating a large app with lots of forms and multiple DataModules. What if I need to make a change sometime in the future. What would happen if I decided to switch to something other than Firebird, say SQLlite? This scares the heck out of me. RAD should also mean Rapid Application Modification.

I hope someone can address these concerns because the DataModule I re-created was identical to the one I originally had, but removed, and then tried to re-add.

lucamar

  • Hero Member
  • *****
  • Posts: 2018
Did you keep around the original DataModule to compare with the new one and see whether there is some difference in the files themselves?

Diffing the original non-working vs. the new working one might be interesting.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

HomerJ

  • New Member
  • *
  • Posts: 13
I did not keep the original. However, this project is just a test, and the DataModule is very simple: one Connection, One Transaction, one SQLQuery, and one Datasource.  I copied them all from the original and pasted them into the new.

I kept the DataModule as created by Lazarus in both cases so I assume the only differences were those I made. I subsequently deleted it before adding the next attempt at using a DM. What seems to have made that second one work (I think) is changing the Transaction Action from the default of RollBack, to CommitRetaining.

Oh, I almost forgot. On the original DM, I added it to the project at at the very beginning. Then I removed it using the IDE's remove utility. When I tried to add it back in, I could not find an "Add to project" utility similar to the one Delphi has. So, I simply added it to the Source, manually. I struggled with that a little because I thought it should be created before the main form -- I've learned I thought wrong. That must have been okay because it worked after changing the Transaction's Action to CommitRetaining.

lucamar

  • Hero Member
  • *****
  • Posts: 2018
[...] When I tried to add it back in, I could not find an "Add to project" utility similar to the one Delphi has. [...]

For future reference, you have basicaly two options to do that:
  • Open the unit.pas file in the editor and use "Project -> Add editor file to project"
  • Open the Project Inspector and click on "Add -> Add files from file system"

The 2nd optoin is the one that more resembles Delphi's "Add to project", IIRC :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

HomerJ

  • New Member
  • *
  • Posts: 13
I think I tried both of those methods, but it was a few days ago, and I can't remember what I had for lunch yesterday. :D  What I do remember is, using at least one of those methods did not add the "create" code to the application, and I had to do that manually (which didn't work either).

It seems as if thinks that belong to the project are recorded somewhere other than the units themselves. For example, if I create a procedure or function, and then decide I don't need it, I delete the routine and its declaration. Then, when compiling, I get a message asking if I want to remove, keep, or abort (paraphrased -- remember -- can't remember yesterday's lunch).  That isn't a problem, but it does make me think there are some record-keeping going on that I'm not aware of. I'm guessing that has something to do with the ability to be cross-platform.

lucamar

  • Hero Member
  • *****
  • Posts: 2018
What I do remember is, using at least one of those methods did not add the "create" code to the application, and I had to do that manually (which didn't work either).

That is done in the "Project Options" (see attached images). Yo have to move the Form/DataModule from "Available forms" to "Auto.create forms".

Quote
It seems as if thinks that belong to the project are recorded somewhere other than the units themselves. For example, if I create a procedure or function, and then decide I don't need it, I delete the routine and its declaration. Then, when compiling, I get a message asking if I want to remove, keep, or abort [...]

That happens with event handlers in a form/datamodule; if you delete them manually from the source file, they are still registered as handling "thisEvent" for "thisComponent" in the form (in memory or in the .lfm file). If you're sure you deleted the method yourself, clicking "remove" deletes that reference without more ado.
« Last Edit: July 08, 2019, 08:45:33 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

HomerJ

  • New Member
  • *
  • Posts: 13
Yes. That's the way I got rid of them. I just need to get used to the differences between Delphi and Lazarus/FPC.  Now I'm struggling with the differences in Randomization.

Thanks for all your help.