Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 540875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:17:08+00:00 2026-05-13T10:17:08+00:00

I am writing a procedure to close all adoquery created and open on a

  • 0

I am writing a procedure to close all adoquery created and open on a (any) form, the problem is I need to do a cast on the form to identify the components. how can I make a dynamic cast like shown in the example?

I need something like this

Procedure OpenADODataSets(Form:TForm;FormType:TClass);
...
...
(Form as FormType).ComponentCount

or

Procedure OpenADODataSets(Form:TForm;FormType:TClass);
...
...
FormType(Form).ComponentCount

this is the code.

Procedure OpenADODataSets(Form:TForm;FormType:TClass);
var
  i: integer;
begin

    for i:=0 to (Form as FormType).ComponentCount-1 do
     if (Form as FormType).Components[i].ClassType=TADOQuery then
       if not TADOQuery((Form as FormType).Components[i]).Active then
        TADOQuery((Form as FormType).Components[i]).Open;

end;

UPDATE

problem solved with the answer of @Edelcom

Procedure OpenADODataSets(Form:TForm);
var
  i: integer;
begin

    for i:=0 to Form.ComponentCount-1 do
     if Form.Components[i].ClassType=TADOQuery then
       if not TADOQuery(Form.Components[i]).Active then
        TADOQuery(Form.Components[i]).Open;

end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:17:08+00:00Added an answer on May 13, 2026 at 10:17 am

    Why do you need the (Form as FormType) (as I commented).
    Looked up some of my own code, which works fine :

    procedure TProgSettingsVisual.FillStandardSaveFilesForForm( const pForm: TForm;);
    var i : integer;
        x : string;
        thisComponent : TComponent;
    begin
       With pForm do
       begin
          for i := 0 to ComponentCount-1 do
          begin
             thisComponent := Components[i];
    
             x := LowerCase(Components[i].ClassName);
    
    
             if x = 'tovcinifilestore'
             then begin
                TOvcIniFileStore(Components[i]).IniFileName := FormSaveFile(pForm);
             end;
    
             if x = 'tovdformstate'
             then begin
                 ...
             end;
    
             if x = 'tovccomponentstate'
             then begin
                  ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a stored procedure where I have an input parameter called my_size
I'm writing a stored procedure that needs to have a lot of conditioning in
I'm new to this. I'm writing a clr stored procedure that calls another stored
When writing a Delphi procedure or function in assembly code, which registers must be
I am writing a stored procedure and within this procedure I am using isNULL.
I'm curious as to the procedure for writing browser plugins for browsers like Chrome,
I am writing Perl regex code to separate out PL/SQL procedure from the package.
In my cruisecontrol build procedure (msbuild) I'm writing to a logfile. This is the
I am messing up somewhere when writing a function to execute stored procedure. I
I usually create my SQL tables and stored procedures by writing a script inside

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.