Welcome, Guest
Username: Password: Remember me
Components and Libraries for Database Development, discussions, problems and suggestions
  • Page:
  • 1

TOPIC:

Problem with ZEOS after upgrate to CT2.50 12 years 2 months ago #1750

  • Radoslaw Rybinski
  • Radoslaw Rybinski's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 3
  • Thank you received: 0
Hello.

I've got some unusuall problem after update to CT2.50 - and, with that - to ZEOS 7.

So - unfortunatelly my database apps stopped working. The problem seem to happen with ZConnection
on OTHER form than ZQuery is.

How to reproduce:
1. Create MainForm : TForm
2. Create DataForm : TDataModule (or TForm also)
3. Put ZConnection on DataForm
4. Put ZQuery on OTHER TForm, and connect it to ZConnection (assigned to file, driver, sqlite3.dll etc)

At this stage ZQuery can execute SQL statements, retrieve fields and so on.
Run the application, and you shall receive "Database connection is not assigned" and then SIGSEGV.

If ZQuery is on the same form with ZConnection - it seems to work. But NOT if they are placed separately.
It does not matter if forms are static or created dynamically (datamodule first).

Moreover - trying to delete such connected ZQuery from form, leads to Access Violation.

Please, help - is it a bug in CT or ZEOS somehow? Anyone has such problems?

Please Log in or Create an account to join the conversation.

Re: Problem with ZEOS after upgrate to CT2.50 12 years 2 months ago #1751

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4518
  • Thank you received: 1102
Sir
first attach is the old pl_ZeosDBO ver 6.6.6 (pl_ZeosDBO_666.zip) from CT 2.40
and
second attach is the lab pl_ZeosDBO ver 7.0.0 (pl_ZeosDBO.zip)
with new SVN "trunk" updates

please test and report
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.

Re: Problem with ZEOS after upgrate to CT2.50 12 years 2 months ago #1767

  • Chris
  • Chris's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 54
  • Thank you received: 4
Hi RRybak

I tried this (exactly as you described) and there is an issue but it's not limited to Zeos version 7 - with CT2.50 I tried the v6.6.6 and v7.0.2 get the same issue on both. I then re-installed CT2.4 and got the same error (this uses 6.6.6 by default) so it would be good to know which version of CT you had this working on - the Zeos 6.6.6 has been the stable version for a few years (and is consistent in most versions of CT) so it may be there's a directive or something causing an issue here (ignored or has other meaning in newer versions of FPC?).

I have a similar problem with a very simple window ms-sql server application (uses NTWDBLIB.DLL) and zeos (both 6.6.6 and 7.0.1/7.0.2 fail with it). Basically at runtime dynamically make a connection to a sql server and run some SQL. The program runs and provides the information but when closing the application causes a SIGSEV error. If I put all the compiler checks in the code generation in the options it appears that the problem is appearing in the ZSQLStrings unit when trying to free the "FParse" TStringlist (in the RebuildAll procedure).

The exact same code in Delphi 2005 runs fine. I put a breakpoint on the same line in both compilers - in Delphi it gets called 4 times before the window is shown and not at all when closing, however in Lazarus it gets called about 20 times before the form appears and again when closing so I suspect it's calling the FParse.Clear function after already "free-ing" the TStringList object. Not sure why there's such a big difference in the calling processes between Delphi and Lazarus.

On which version of CT did it work?

TheBlackSheep

Please Log in or Create an account to join the conversation.

Re: Problem with ZEOS after upgrate to CT2.50 12 years 2 months ago #1768

  • Chris
  • Chris's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 54
  • Thank you received: 4
Hi RRyback

I think I found your problem and it's not CT or Zeos - it's the fact that although the component has recognised there is a connection on a datamodule not on your current form it doesn't actually link in the unit until you add in the unit to the uses clause (Delphi wouldn't even recognise you had a connection on another form until you'd added it to the uses clause). Not sure why it used to work but now doesn't as I'd have thought it should never have worked - anyway, just add the datamodule unit name to the uses clause and then it should work.

Edit: Interestingly, once you've added it and compiled the application, removing the datamodule unit name from the uses clause doesn't seem to make the issue appear again - that one doesn't make sense!

It doesn't fix my problem but hopefully yours is sorted.

TheBlackSheep

Please Log in or Create an account to join the conversation.

Last edit: by Chris. Reason: Update

Re: Problem with ZEOS after upgrate to CT2.50 12 years 2 months ago #1769

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4518
  • Thank you received: 1102
Guys,
a new SVN revision 1082 for ZEOSBD
more info here

Please, test and report
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Re: Problem with ZEOS after upgrate to CT2.50 12 years 2 months ago #1773

  • Chris
  • Chris's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 54
  • Thank you received: 4
Hi Sternas

I think RRyback's issue is sorted if he just adds the datamodule to his uses clause.

I didn't want to hijack RRyback's but I think my issue appears to be with the mssql driver/support in Zeos - the heap checks reports it doesn't deallocate memory correctly - I've show the code I'm using below;
procedure TfrmSimpleDataPump.BitBtn2Click(Sender: TObject);
var T:TStringList;
begin
  if (edHostname.Text <> '') then begin
    zconnSQLServerSource.HostName:=edHostname.Text;
    zconnSQLServerSource.User:= edUsername.text;
    zconnSQLServerSource.Password:= edPassword.text;
    zconnSQLServerSource.Database:=edDatabase.Text;

    try

      try
        zconnSQLServerSource.Connect;

        if zconnSQLServerSource.Connected then begin

          zroDatabase.Open;
          if zroDatabase.Active then begin
            T := TStringList.Create;

            zroDatabase.First;

            while not zroDatabase.EOF do begin

              T.Add( zroDatabase.FieldByName('table_name').asString);
              zroDatabase.Next;

            end;

            ShowMessage(T.Text);

            T.Free;
          end;
          zroDatabase.Close;
        end;

      except
        on E:Exception do ShowMessage('That didn''t work! the error was;'+E.Message);
      end;

    finally
      zconnSQLServerSource.Disconnect;
    end;
  end;
end; 


zroDatabase is a zeosreadonly query component and the zconnSQLServerSource is a zeos connection, the 4 ed... components are just TEdit's to set the various logon parameters to the database itself. The program just lists all the tables in a database using the following SQL (of course specific to mssql);
SELECT o.name Table_Name, c.name Column_Name, t.name DataType, c.Length, CASE WHEN c.isnullable=1 THEN   'Yes'   ELSE   'No'   END AS 'Nullable'
FROM sysobjects o
INNER JOIN syscolumns c ON (o.id=c.id and o.type='U' and o.name not like 'dt%')
Inner Join systypes t ON (c.xtype=t.xtype) 
order by o.name, c.name;

It does report the list but when existing throws a sigsev so it's not freeing something correctly but it might be peculiar to using the mssql option.

The new version you attached doesn't change anything as far as this is concerned - i.e. it still errors but it might have been like that for a lot of the versions of CT/FPC/Lazarus).

TheBlackSheep

Please Log in or Create an account to join the conversation.

Re: Problem with ZEOS after upgrate to CT2.50 12 years 2 months ago #1774

  • Chris
  • Chris's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 54
  • Thank you received: 4
Have reinstalled everything for CT2.5 (including the latest Zeos 7.0.3 you sent last night/this morning) and it appears to have started working and no longer erroring. I pointed it at a MySQL database first and that worked so repointed it at a MSSQL database and it didn't bork.

I did find a different ntwdblib.dll on the web (a version from 2004, which is earlier than the one I was using initially) so am now using that. I may have also had some kind of corruption in the lfm files (component names were still there in the form class but weren't showing on the form so I had to remove them manually). Two machines reported the same issues but it may have been because the project was corrupt and that the problems were just being transferred between the two systems.

Thanks again Sternas for your (and all your guys) hard work - CT is really a great addition to FPC/Lazarus community and I look forward each month to the next development of this.

TheBlackSheep

Please Log in or Create an account to join the conversation.

Re: Problem with ZEOS after upgrate to CT2.50 12 years 2 months ago #1775

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4518
  • Thank you received: 1102
Thanks Sir
we will update ZeosDB session in next CT 2.60,
with samples etc...

Oh, a big thanks from my team,
a smile of success to their faces, from your post.
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Re: Problem with ZEOS after upgrate to CT2.50 12 years 2 months ago #1780

  • Radoslaw Rybinski
  • Radoslaw Rybinski's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 3
  • Thank you received: 0
OK, and here I am also... Thanks, for you answers. It took me some time, but.. Unfortunatelly I didn't manage to run either of the first supplied versions (6 and 7).
To exclude possibility of some interferences (ie. Commodo Firewal Defense) I did set up two virtual box machines - windows xp, and windows 7 - both clean, with no securities. It did not help either.
Now I have downloaded latest version supplied by You today (pl_ZeosDBO_2012_3_20). I've overwritten both pl_zeosdb directories in "components" and "mod", and did a "Clean & Build" From lazarus menu.
I gave included "uses unit2" in main form (unit2 is data module), but it screams still about not assigned data connection at runtime.

One thing that looks repaired is, that there is no more "Access violation" problem at closing projects.

As I see TheBlackSheep has managed to solve such problem. Did I something wrong in the rebuild process?

Please Log in or Create an account to join the conversation.

Re: Problem with ZEOS after upgrate to CT2.50 12 years 2 months ago #1781

  • Chris
  • Chris's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 54
  • Thank you received: 4
Hi RRyback

I just did what you'd suggested was giving you problems and in previous versions it did (and by adding the unit reference it cured the problem - at least for me);

I created a new project and dropped a Zeos TReadOnlyQuery component on it. Then I created a new DataModule and dropped a Zeos TZConnection on it. At this point I attached the connection property of the TReadOnlyQuery component to the TZConnection (this shouldn't strictly be allowed as the datamodule isn't referenced in the main form unit) - I then setup the connection on the datamodule to a local mysql database and added a sql string in the query component - a button, datasource and grid to the main unit just to see the data and ensure it was working - added "ZReadOnlyQuery1.Open;" to the button click event and ran the application.

In the previous Zeos libraries I as getting complaints about the database reference being missing and this seemed to be fixed after adding the datamodule unit to the main unit - although have just tried it now with the latest version and (without adding the datamodule reference to the main unit) it works without the datamodule being added to the main unit uses clause. I don't know if this is because of the latest Zeos library and it's so much hassle to switch backward and forward I'm not going to go down that route again.

What database are you using and when did it work last (i.e what version of CT)? For this testing I'm setting the database connection details on the component itself and not dynamically at runtime (from TEdit's etc) - on the connection I'm setting both the catalog and the database properties to the same database (might be only relevant for MySQL) - I'm also using the libmysql.dll (not the "libmysqld.dll")

Interestingly, if you get it connecting (at design time) and remove the database properties from the ZConnection - the application seems to know which database you want - probably because the current database has been set (i.e. the "USE ..." command in MySQL) - of course in a live scenario the current database could be anything so this is not a good idea.

If you are adding the database connection parameters at runtime (i.e. not at design time) at what point are you setting them?

TheBlackSheep

Please Log in or Create an account to join the conversation.

Re: Problem with ZEOS after upgrate to CT2.50 12 years 2 months ago #1782

  • Radoslaw Rybinski
  • Radoslaw Rybinski's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 3
  • Thank you received: 0
Hi,

I am using SQLite-3 protocol and sqlite3.dll. For now did everything as described above. Lat version it worked for me was in CT 2.40 (the last one before the Zeos up to 7 update).
I am afraid it is all messed up with all this component switching. I will try to download CT 2.40 and CT 2.50 from scratch, and build it from the start. 2.40 - as is, 2.50 with svn sources supplied yesterday by Sternas.

I cannot afford static link to database. The schema follows:
1. create splash form
2. load config from file - if not found - create database (ConfigForm) - at this stage it works, because MainDB Connection and it's test ZQueries are on the same form. Data module is now created (with simple Create)
3. When all is set MainForm is created with CreateForm (as main for the application). Now in 2.40 it knew it should reference to DataModule (which already exists and is connected). In 2.50 it does not.

More over - attempting a hack: placing SECOND ZConnection for ZQueries at main form, and after FormCreate switching them to "DatamModule.ZConnection" at runtime does not work either. Funny is, that this Connection is "visible", NOT null, and assigns. But after using ZQuery->Open I ended with "Dataconnection not assigned" and/or Access Violation (SigSegVs).

I will get to test it further, but it will take me few more days due to low time lately. Or perhaps CT 2.60 will be released earlier :)

Please Log in or Create an account to join the conversation.

  • Page:
  • 1