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

  • SEARCH
  • Home
  • 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 one stored procedure, i need to pass start and end date
When writing a procedure in PL/SQL, I can declare a parameter's type as myTable.myColumn%TYPE
I am writing a stored procedure in MySQL Community Server 5.5.16 and I need
I am writing a stored procedure which collects all changes that were happend in
I'm writing an application with Java Swing. What i need is a procedure where
I was just writing a procedure that is looking for a newline and I
I am writing a procedure where each call it needs to get a single
I am writing a procedure which is related to apple apns feedback. I have
I am writing a stored procedure with 3 parameters and my where clause changes
I am writing a stored procedure that when completed will be used to scan

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.