0

I'm using SQL Server 2017 and ADO components with Delphi, creating an FMX application for Windows.

In the DataModule, I've added a TADOConnection and some TADOTable and TADOQuery components. In the DataModule's OnCreate event, I have the following code:

ADOConnection.Connected := False;
AppINI := TIniFile.Create(ExtractFilePath(ParamStr(0))
 + 'AutoReg.INI');
try
 fDatabase := AppINI.ReadString('DatabaseParms','Database','xxx');
 ConnectStr := AppINI.ReadString('Initialization','Connection','');
finally
 AppINI.Free;
end;
ADOConnection.DefaultDatabase := fDatabase;
if ConnectStr > '' then
 ADOConnection.ConnectionString := ConnectStr;
try
 ADOConnection.Connected := True;
 for i := 0 to ComponentCount-1 do begin
 if Components[i] is TADOTable then begin
 TADOTable(Components[i]).Open;
 end;
 end;
except
 on E: Exception do
 ShowMessage(E.Message);
end;

In Delphi 11 (Alexandria), this works fine. But in Delphi 13 (Florence), I get an error when opening the TADOTable:

invalid variant operation

I've tracked this down to code in the UpdateIndexDefs function in the Data.Win.ADODB unit. The line:

LPos := IndexInfo.Fields[SOrdinalPosition].Value;

which returns an "unknown type 14" when checking the value of LPos.

I've tried switching from the SQLNCLI11 provider to the SQLOLEDB provider, but get the same error. I've also tried adding an IndexName and removing the value in the TADOTable properties, but no change there, either.

I'm not sure what else to try or change to resolve the problem. I'm happy to post more code if it would help, just let me know what else to add.

Remy Lebeau
610k36 gold badges516 silver badges875 bronze badges
asked Oct 20, 2025 at 22:04
3
  • Are you sure it worked with the same data in Delphi 11? Type 14 in this context probably refers to DECIMAL values packed into SQL_VARIANT types and, AFAIK, Delphi doesn't support unpacking those. Commented Oct 20, 2025 at 22:22
  • Yes. I still use the version in Delphi 11 now (it is an interna1 application for my business). I was in the process of upgrading to the latest version of Delphi. Commented Oct 21, 2025 at 14:55
  • So I created a blank project and replicated my data module and it ran fine as a 32-bit application, but when I ran it as a 64-bit application the exception occurred. Same code, just different targets. I'm not clear what difference that would make in terms of opening the TADOTable object. Commented Oct 22, 2025 at 20:53

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.