Icon View Incident Report

Serious Serious
Reported By: Magnus Rosendahl
Reported On: 12/19/2008
For: Version 4.27 Build 1
# 2886 Delphi 2009 String Parameter Assignments Does Not Set Data Type of Parameters Properly

I encountered an error when upgraded a Delphi project from D2007 (DBISAM426b3) to D2009 (DBISAM427b1).

Consider the following code snippet. This code ran fine with 4.26 but gives an error in 4.27.

Exception EDatabaseError 'Query: Field 'F1' is of an unknown type.'

Problem is I assign a Variant to Param.Value, and the datatype is not automatically set. I could of course solve this by checking the VarType of the value to be assigned and then use the assignment function AsInteger, AsString etc.

But since it worked in the previous DBISAM version I thought you might want to look at it. I suspect the error is related to the fact that variant strings are no longer varString by default but varUString.

  //Query = TDBISAMQuery
  //sql = SELECT * FROM T WHERE F1=:P1 AND F2=:P2
  //WhereFields = array of string
  //WhereValues = array of Variant

  with Query do
  begin
    SQL.Clear;
    SQL.Add(sql);
    for i := Low(WhereFields) to High(WhereFields) do
      ParamByName(WhereFields[i]).Value := WhereValues[i];
    Open;
    ...
  end;



Comments Comments and Workarounds
The workaround is to manually set the TDBISAMParam.DataType to ftString in Delphi 2009.


Resolution Resolution
Fixed Problem on 12/20/2008 in version 4.27 build 2


Products Affected Products Affected
DBISAM VCL Client-Server
DBISAM VCL Client-Server with Source
DBISAM VCL Standard
DBISAM VCL Standard with Source
DBISAM VCL Trial

Image