Page 1 of 1

TMyQuery AutoPrepare with Store Procedure -> Net Package Err

Posted: Tue 07 Dec 2010 10:59
by Justmade
I don't know if it is a bug or not and it actually do not bother me much.

I just encounter this issue and think it is good to let you know so you can choose to just ignore it or do something to it.

My auto generated TMyQuery Components default to AutoPrepare. When I use one such Query to run a Store Procedure statement (Call XXXX(YY,ZZ);), it generate Net Package out of order : received[XX], expexted[1]

If I turn off AutoPrepare, then everything is OK.

I understand I should not prepare a call to store procedure, but generating an appropriate error seems to be better then throwing a Net Package out of order error, which will take someone like me to spends more time to find out what the problem is.

Posted: Tue 07 Dec 2010 14:10
by Dimon
Please specify the Delphi version and the MyDAC version you are using.

Posted: Tue 07 Dec 2010 22:59
by Justmade
Delphi 2010 with 6.00.0.2 of MyDAC

Posted: Wed 08 Dec 2010 14:09
by Dimon
I could not reproduce the problem. This problem can arise in a multithreaded application. Please check that you don't use one connection for more than one thread simultaneously.

Posted: Thu 09 Dec 2010 06:46
by Justmade
Using your demo database

Code: Select all

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, JMIntfComponents, DB, MemDS, DBAccess, MyAccess;

type
  TForm1 = class(TForm)
    con1: TMyConnection;
    q1: TMyQuery;
    btn1: TJMButton;
    procedure btn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btn1Click(Sender: TObject);
begin
  q1.Active := False;
  q1.Active := True;
end;

end.

Code: Select all

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 290
  ClientWidth = 554
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object btn1: TJMButton
    Left = 96
    Top = 120
    Width = 75
    Height = 25
    Caption = 'btn1'
    TabOrder = 0
    OnClick = btn1Click
    Rights = 
    Langs = 
  end
  object con1: TMyConnection
    Database = 'test'
    Port = 3306
    Username = 'root'
    Password = 'xxxxxx'
    Server = 'localhost'
    LoginPrompt = False
    Left = 36
    Top = 40
  end
  object q1: TMyQuery
    Connection = con1
    SQL.Strings = (
      'call sel_from_emp')
    Options.AutoPrepare = True
    Left = 116
    Top = 44
  end
end
The first time you click btn1, no problem. The 2nd time you click it, that error occurs.

Posted: Thu 09 Dec 2010 13:27
by Dimon
We have investigated this problem. It connected with the specificity of MySQL work with prepared stored procedures. To sovle the problem, please use the TMyStoredProc component to execute a stored procedure.

Code: Select all

  MyStoredProc1.StoredProcName := 'sel_from_emp';
  MyStoredProc1.Execute;

Posted: Fri 10 Dec 2010 02:38
by Justmade
Thanks for your time investigating.

As I said in the first post, I know it is not appropriate to use TMyQuery for a Store Procedure and even make it prepared.

As My Query components are automatically generated and my inherited Component from TMyQuery had intensive coding, and many of my other codes assume those Query to be that TMyQuery descendent, using TMyStoredProc is not an options for me. It is my own problem, though. And I just disable the Autoprepare and work great.

I only want to let you know this issue and said that if a more accurate error is raised, it can be better for other who encounter this problem.

Thanks again for taking time to deal with this non-bug issue.