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 8192963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:18:59+00:00 2026-06-07T04:18:59+00:00

Because of code redundancy I generalized the usual ADOQuery handling into a method of

  • 0

Because of code redundancy I generalized the usual ADOQuery handling into a method of its own, with the method returning the _RecordSet of the query.
Now, when I check the query results inside that method, they check out alright. But the returned _RecordSet seems to be empty or nil (Exception: EOleException ‘Item cannot be found in the collection to the corresponding name or ordinal.’)
From what I gathered, I seem to need to return a clone of the query’s _RecordSet. So far I have tried using

res := qr.Recordset.Clone(adLockUnspecified); Result := res;,

TADOQuery.RecordSet._xClone() method

unsuccessfully, as well as THESE methods, none of which worked (several components not recognized, version differences I’m guessing).

The code I use for querying:

function queryDb(const s: WideString; const dc: boolean = true): _RecordSet;
var
  ds: String;
  conn: TADOConnection;
  qr: TADOQuery;
  res: _RecordSet;
begin
  Result := nil;
  conn := TADOConnection.Create(nil);
  qr := TADOQuery.Create(nil);
  try
    ds := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='
          + ExtractFilePath(Application.ExeName)
          + 'gdkp.mdb;Persist Security Info=False';
    conn.ConnectionString := ds;
    conn.LoginPrompt := false;
    conn.Connected := true;
    qr.Connection := conn;
    if(dc = true)then begin
      qr.DisableControls
    end;
    qr.SQL.Add(s);
    qr.Open;
    Result := qr.Recordset;
  finally
    conn.Free;
    qr.Free;
  end;
end;

Has someone overcome this problem before and knows a suitable answer or can direct me towards helpful content?

  • 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-06-07T04:19:01+00:00Added an answer on June 7, 2026 at 4:19 am

    I don’t know which of your crazy antics is more crazy:

    1. Setting up and connecting to a database inside a function and doing your queries inside this function, connecting to the database EACH TIME YOU QUERY, is going to be insanely slow.

    2. ADO Query objects should have a longer lifetime than the insides of a function. This is a code smell, a severe one.

    3. Keep the recordset inside the query where it belongs.

    4. Normal people create TDataModules and leave their objects around for the lifetime of their app, and requery using this code:

      query.Active := false;
      query.Active := true;

    Watch your app speed up when it doesn’t have to connect to the database, create and tear down a connection and a query, each time you want some data.

    What on earth are you doing with the _recordsets youre getting back? Did you learn ADO in C# and you’re trying to use C# ADO.net idioms in Delphi? Don’t. Stop doing that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need start off with code because I am not sure what terminology to
I am stuck on this one piece of code because I can't get the
I am making UI in android using java code because all UI information comming
I'm trying to speed up my code because it's running very long. I already
I think I might be causing a bug in my code because I'm unclear
I'm really thrilled, because my code works great for me (se below), however I
Hey, I don't have any code because I don't know how to do this.
I wrote an android app for someone, but they want the source code because
I need someone to lead/guide me where have I code wrongly because I can't
I think allowing recursion can be very handy sometimes, not because I can code

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.