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

The Archive Base Latest Questions

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

I need to make a long running task in the background. I’m using OmniThreadLibrary

  • 0

I need to make a long running task in the background. I’m using OmniThreadLibrary hopping this could help me.

I use dbexpress+mssql driver. I can connect ok when is in the main thread, but get:

Project Project1.exe raised exception class TDBXError with message
‘DBX Error: Driver could not be properly initialized. Client library
may be missing, not installed properly, of the wrong version, or the
driver may be missing from the system path.’.

The connections are created in each thread, not shared datamodule:

type
  TdbManager = class(TObject)
  private
    { private declarations }
    FCon: TSQLConnection;
  public
    { public declarations }
    procedure Open(Driver:String; aparams:TStringList);overload;
    procedure Close;

    constructor Create;
    destructor Destroy;override;
  end;

  constructor TdbManager.Create;
begin
  inherited Create;
  FCon := TSQLConnection.Create(nil);
end;

procedure TdbManager.Open(Driver: String; aparams: TStringList);
var
  i: Integer;
  key:string;
begin
  FCon.DriverName := Driver;

  for i := 0 to params.Count - 1 do
  begin
    key := params.Names[i];
    FCon.Params.Values[key] := params.Values[key];
  end;

  LogMsg('Open DB '+ Driver + ': ' + FHost + '\' + FDatabase);

  FCon.Open;
  LogMsg('Done.');
end;

And the background task is executed:

procedure TBackupPlan.OnScheduleTrigger(Sender: TScheduledEvent);
begin
  Parallel.Async(procedure
  begin
    ExecuteDataTask( Sender.Name );
  end);
end;

procedure TBackupPlan.ExecuteDataTask(const Name: String);
var
  db:TdbManager;
begin
  db := nil;

  db := TSqlServerManager.Create;
  db.Open(self.Driver, options);

  result := db;
end;

If I execute this directly, open ok. If I use Parallel.Async then get the error. What is happend here?

  • 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-29T10:45:14+00:00Added an answer on May 29, 2026 at 10:45 am

    I found information about this here:

    http://docwiki.embarcadero.com/RADStudio/en/DbExpress_Database_Specific_Information

    MSSQL Driver Requires Calls to CoInitialize and CoUninitialize for Console Applications and Worker Threads

    The MSSQL driver does not call CoInitialize or CoUninitialize. Earlier
    versions of the MSSQL driver, which is a COM driver, called
    CoInitialize and CoUninitialize directly, which is not a good
    practice. VCL applications take care of these calls for you, so VCL
    applications do not require calling CoInitialize and CoUninitialize.
    However, applications using the MSSQL driver in console applications
    or in worker threads need to call CoInitialize/CoUninitialize. If this
    call is not made, you will see the following error message: “DBX Error: Driver could not be properly initialized. Client library may be
    missing, not installed properly, of the wrong version, or the driver
    may be missing from the system path.” For help on CoInitialize, see
    the CoInitialize Function on MSDN.

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

Sidebar

Related Questions

My application is using an image processing library to handle a long running task.
I am working with TPL and need to have a long running TPL task
I am trying make long screen to vertical direction. So, I need a screen
I need to make changes to an in-use production database. Just adding a few
To not make a short story long, my teacher makes us use a MASM.EXE
I have a particularly long running method that I need to execute from my
I have a need to add a timeout to a long running thread. We're
I need some help understanding how 32 bit applications use memory on a 64
I have to start a thread to do some long running task in the
I have a crystal report file I need make a tiny edit in. It

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.