?
Solved

Iterating through datamodule components fails with persistent fields

Posted on 1999-11-24
8
Medium Priority
?
247 Views
Last Modified: 2010-08-05
Hi,

I have a piece of code on a OnCreate event of a datamodule which looks as follows:

----------------------
  try
    if not SS.Active then
      SS.Active := TRUE;

    DB.Connected    := FALSE;
    DB.SessionName  := SS.SessionName;
    DB.DatabaseName := 'DB' + SS.SessionName;
    DB.Connected    := TRUE;


    for I := 0 to (ComponentCount - 1) do
    begin
      if (Components [I] is TTable) then
      try
        TTable (Components [I]).Active       := FALSE;
        TTable (Components [I]).SessionName  := SS.SessionName;
        TTable (Components [I]).DataBaseName := DB.DatabaseName;
        TTable (Components [I]).Active       := TRUE;
      except
        ...
        raise;
      end;
      if (Components [I] is TQuery) then
      try
        TQuery (Components [I]).Close;
        TQuery (Components [I]).SessionName  := SS.SessionName;
        TQuery (Components [I]).DataBaseName := DB.DatabaseName;
      except
        ...
        raise;
      end;
    end;

    QEmpSel.Active  := TRUE;
    QEmpresa.Active := TRUE;

  except
    ShowMessage ('ERROR');
    Application.Terminate;
  end;
-------------------
(Hope you can see it OK)

What is makes is to assign the session and database names to all the tables and queries in the data module.

Well, it works ONLY IF THERE IS NO PERSISTENT FIELDS IN THE TABLES.

I mean, if I click twice on a table and add all fields (or even only one) onto the fields editor, it stops working.

WHY?
HOW TO CORRECT THIS BEHAVIOUR?

Thanks

0
Comment
Question by:Felixin
8 Comments
 
LVL 17

Expert Comment

by:geobul
ID: 2231580
Hi Felixin,
What kind of Database you use ?
I've tried your code with some DB's and did not found any problem.

geobul
0
 
LVL 2

Author Comment

by:Felixin
ID: 2231651
Hi,

MS SQL 6.5

is what I'm using
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2233537
hi felixin,

could it be that the tablestructures are different, becuase a persistent field does not have a database-property nor a session-property, therefore your changes should not affect problems with persistence-fields, except the dataset-structure is changed or the fieldname does not match.

meikl
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
LVL 2

Author Comment

by:Felixin
ID: 2233685
Please forget about persistent fields:

I have just discovered that it fails when 32 datasets (TTables/TQueries) are already opened.

Is there a limit, in the BDE or in the MS SQL, for the number of open objects connected to a database and to a session?

(I Know it exists for dBase and Paradox:
TI2751)

For kretzschmar :

In any case, what you are pointing might be posible, but, how could it be?:
I'm not changing the information that is set when I make an "add all fields" on the fields editor and, I swear, I'm not changing the table structure at run time.

Thanks
0
 
LVL 17

Expert Comment

by:geobul
ID: 2234270
Hi,

First: it's in BDE.

Use BDE Administrator utility to increase MAXFILEHANDLES in
Configuration - System - INIT
to the apropriate value.

Geo
0
 
LVL 2

Author Comment

by:Felixin
ID: 2234365
See my own answer

(I've found the solution)
0
 
LVL 2

Author Comment

by:Felixin
ID: 2234419
ATTENTION:

Any answer received since now will be rejected.

I HAVE DISCOVERED THE ANSWER ON MY OWN:

MAX DBPROCESSES must be set to a number bigger than the number of datasets you expect to open.

I changed it from 31 to 64 and it worked.

For geobul:

Some words to you:

The MAXFILEHANDLES should be changed when you are using dBase or Paradox tables, as they are stored in files.
It is useless for SQL dtabases
(I believe).

Thanks to all of you.
0
 
LVL 5

Accepted Solution

by:
ianB earned 300 total points
ID: 2249500
Hi,

I am answering this question so it can be saved as a PAQ. I have refunded the points back to your account.

Ian
Community Support @ Experts Exchange
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Planning to migrate your EDB file(s) to a new or an existing Outlook PST file? This video will guide you how to convert EDB file(s) to PST. Besides this, it also describes, how one can easily search any item(s) from multiple folders or mailboxes…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question