Page 1 of 1

Problem with TIBCSQL.Execute method in multithread applicati

Posted: Sat 09 Jul 2011 16:45
by adm.nilser
Hello, i'm testing the lastest IBDAC version with a multithread application, and when i try to execute TIBCSQL.Execute method i have a access violation exception.
i tested the method with a simple application, then working fine.
Any idea about this issue??

Posted: Mon 11 Jul 2011 09:50
by AndreyZ
Hello,

Such problems can occur in the multithreaded application if you are using one connection in several threads. To solve the problem, you should have a separate connection in each thread.

Posted: Mon 11 Jul 2011 19:05
by adm.nilser
Hi, AndreyZ!!

there's a unique connection for each thread, I already checked this.
I see in the othes topics that some users has the similar problem.

Any idea?

Posted: Tue 12 Jul 2011 06:23
by AndreyZ
Please try composing a small sample to demonstrate the problem and send it to andreyz*devart*com, including a script to create server objects. Also please specify the following:
- the exact version of your IDE;
- the exact version of Firebird or InterBase.

Posted: Tue 19 Jul 2011 12:55
by imeyer
Hello adm.nilser

i have had the same problem and solved it in this way

change in the IBCall.pas the line 2840(2841) like this

EnsureThreadSafety:=false;
// EnsureThreadSafety := (Version = 6);

this works for me my multithreading application is running a connection in each thread

Posted: Wed 20 Jul 2011 02:31
by adm.nilser
I'm using the demo version.
I haven't the source code to make this changing.
But, I can change the ThreadSafetyClientLibrary variable value to False. Is it the same thing??

Posted: Wed 20 Jul 2011 16:06
by imeyer
no that's not the same thing i tried this as well but it do not work in the way i excpected it. So i started to debug it and have found out that the mention
Variable "EnsureThreadSafety" is become always true in my constalation.

After changin it to false the application works fine.

Posted: Thu 21 Jul 2011 07:12
by AndreyZ
The point is that the client library can be not threadsafe, and that can cause different random errors in a multithreaded application. The EnsureThreadSafety variable helps to avoid these errors. If the client library isn't threadsafe, IBDAC implements thread-safety by itself. For example, if you are using Firebird 2.5, IBDAC won't implement thread-safety by itself, but if you are using any previous Firebird version, IBDAC will implement thread-safety.

to imeyer:
In the latest IBDAC version 3.60.0.24 we fixed the problem with the EnsureThreadSafety variable for RAD Studio 2009 and higher. Please try using the IBDAC version 3.60.0.24 and check if the problem persists.

to adm.nilser:
The problem you described can be caused by different reasons. That's why it's better if you compose a small sample that demonstrates this problem and send it to me. This way I will be able to investigate the problem and find a solution. Please provide me all information I asked you in my previous post.

Posted: Tue 26 Jul 2011 12:15
by adm.nilser
Hi, I discovered the problem. It's occurs when I try to use blob params.
I implemented a class inherited from TIBCQuery called TIBXQuery that declares a method called SetParam.

TIBXQuery = class(TIBCQuery)
public
procedure SetParam(AParam: String; AValue: Variant; AType: TFieldType);
end;

The SetParam method's code is:

procedure TIBXQuery.SetParam(AParam: String; AValue: Variant; AType: TFieldType);
var
lParam: TParam;
begin
lParam := ParamByName(AParam);
lParam.DataType := AType;
lParam.Value := AValue;
end;

If local variable lParam is a blob param, a exception occurs.
This method only works if I change the AValue parameter's type to String and set lParam variable as lParam.AsMemo := AValue;

I'm using the version 3.60.0.24 of IBDAC.

Any sugestion??

Posted: Wed 27 Jul 2011 10:16
by AndreyZ
To solve the problem, you should use TIBCParam instead of TParam in the following way:

Code: Select all

procedure TIBXQuery.SetParam(AParam: String; AValue: Variant; AType: TFieldType);
var
  lParam: TIBCParam;
begin
  lParam := ParamByName(AParam);
  lParam.DataType := AType;
  lParam.Value := AValue;
end;

Posted: Thu 28 Jul 2011 11:05
by adm.nilser
Thanks, Andreyz!!

This code working fine.

Posted: Thu 28 Jul 2011 11:14
by AndreyZ
Feel free to contact us if you have any further questions about IBDAC.