Page 1 of 1

EnableBCD option is not working in version 4.45.0.18

Posted: Tue 22 Sep 2009 11:13
by uberbach
After updating dbexpsda.dll to version 4.45.0.18, the EnableBCD option doesn't seem to work anymore. I get a "BCD Overflow" exception when calling a stored procedure with a numeric parameter. I want to access this parameter as a ftFloat, so I have to set EnableBCD to false, but it has no effect.

To reproduce the problem, create this stored procedure:

Code: Select all

create  proc dbo.sp_test @test numeric(12,2)
as
Begin
	set @test = @test
End
Then call it from Delphi:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  Connection: TSQLConnection;
  Dataset: TSQLDataset;
begin
  Connection := TSQLConnection.Create(self);
  try
    with Connection do begin
      LoginPrompt := False;
      DriverName := 'SQLServer';
      GetDriverFunc := 'getSQLDriverSQLServer';
      LibraryName := 'dbexpsda.dll';
      VendorLib := 'sqloledb.DLL';
      Params.Values['Database'] := MyServer + '/' + MyDatabase;
      Params.Values['User_Name'] := MyUserName;
      Params.Values['Password'] := MyPassword;
      Connected := True;
      SQLConnection.SetOption(TSQLConnectionOption(102), Integer(False));
    end;

    Dataset := TSQLDataset.Create(self);
    try
      with Dataset do begin
        SQLConnection := Connection;
        CommandType := ctStoredProc;
        CommandText := 'sp_test';
        ParamByName('test').AsFloat := 0;
        ExecSQL; // <-- BCD Overflow!
      end;

    finally
      Dataset.Free;
    end;

  finally
    Connection.Free;
  end;

end;
I've tested the same code on a 3.10.8.0 version of dbexpsda.dll, and it works fine. I'm using Delphi 7 and MS SQL Server 2000.

Posted: Wed 23 Sep 2009 08:08
by Dimon
This problem is connected with dbExpress processing TSQLStoredProc parameters, and not with DbxSda. dbExpress requires setting parameter value only in the specified type. The coEnableBCD options is not used in created paramater type.
In order to solve the problem you should use the following code to assign parameter value:

Code: Select all

Dataset.ParamByName('test').AsFMTBCD := VarToBcd(0);

Posted: Wed 23 Sep 2009 08:50
by uberbach
If I run the same test with an older dbexpsda (I used version 3.10.8.0), then everything works as expected. That is, when EnableBCD is true, you get a "BCD Overflow" error, but when EnableBCD is False, it works fine. When I use the newest version, I allways get the overflow error, no matter what value EnableBCD has.

I could, of course, use your solution, but that would mean going though thounsands of lines of code. I would prefer it if dbexpsda stayed compatible with older versions.

Posted: Thu 24 Sep 2009 07:56
by Dimon
Thank you for information. We have fixed this problem. This fix will be included in the next DbxSda build.