MyQuery CommandTimeout Not Work

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
multimesut
Posts: 18
Joined: Mon 28 Nov 2011 18:04
Location: Türkiye

MyQuery CommandTimeout Not Work

Post by multimesut » Sat 09 Feb 2019 12:53

Hi,

I want to do 5 seconds after close the query. and give an error. but "CommandTimeout" does not work. always set to infinite. The query takes 2 minutes.

Thank You

MyDAC 9.3

Code: Select all

  try
  MyQuery1.CommandTimeout:=5;
  MyQuery1.SQL.Clear;
  MyQuery1.SQL.Add('SELECT * FROM test''');
  MyQuery1.Open;
  except
  showmessage('error');
  end;

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: MyQuery CommandTimeout Not Work

Post by ViktorV » Mon 11 Feb 2019 15:41

This property sets the time to wait before quitting an attempt to execute a command and generating an error.
Please note that this is the waiting time for any response from the MySQL server after the command has been sent to the server, and it does not include the time required for fetching data if the command retrieves some data.

multimesut
Posts: 18
Joined: Mon 28 Nov 2011 18:04
Location: Türkiye

Re: MyQuery CommandTimeout Not Work

Post by multimesut » Wed 13 Feb 2019 06:26

hi, but I have to put a period to wait for a long time. sql maybe busy. I should not wait until that time

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: MyQuery CommandTimeout Not Work

Post by ViktorV » Wed 13 Feb 2019 09:17

To solve your task, you can set FetchAll property to False. The TMyQuery component has the FetchAll and FetchRows properties, which default values are True and 25, correspondingly. If FetchAll = False, only FetchRows of rows will be read during the fetch of the TMyQuery.Open method. The rest of the rows will be fetched by necessity. When scrolling, in DBGrid, the next part of rows will be fetched. You can read about it in the MyDAC help: https://www.devart.com/mydac/docs/?deva ... tchall.htm

multimesut
Posts: 18
Joined: Mon 28 Nov 2011 18:04
Location: Türkiye

Re: MyQuery CommandTimeout Not Work

Post by multimesut » Wed 13 Feb 2019 11:34

The query return is a single line but sometimes it takes too long because there are calculation operations in it.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: MyQuery CommandTimeout Not Work

Post by ViktorV » Wed 13 Feb 2019 12:54

You can create multithreaded application and handling background queries manually. But you have to use one MyConnection instance per thread.

Post Reply