Can't assign a property of an automation object

Hi! In short the problem is as follows: I don’t know how to assign a property of one Automation object to other automation object. The code is: CREATE (SQLConnection); SQLConnection.Open (‘User ID=…;Password=…;Data Source=…;Initial Catalog=…’); CREATE (SQLCommand); SQLCommand.ActiveConnection := SQLConnection; SQLCommand.CommandType := 1; SQLCommand.CommandText := ‘select * from dbo.[…]’; The type of SQLConnection is “Microsoft ActiveX Data Objects 2.8 Library”.Connection The type of SQLCommand is “Microsoft ActiveX Data Objects 2.8 Library”.Command Compiler generates error at the line SQLCommand.ActiveConnection := SQLConnection;. The error message goes as follows: “Type conversion is impossible Text := Automation” Thanks in advance.

The method you are trying is very reasonable, and in most languages (VB, VBA, VBScript, etc.) is exactly correct. I think the difficulty lies in the fact that the ‘ActiveConnection’ property is overloaded to take two argument types: 1) an open Connection object reference (this is the most common usage…), or 2) a connection string. Here’s a quote taken from


To create a Command object independently of a previously defined Connection object, set its ActiveConnection property to a valid connection string. ADO still creates a Connection object, but it doesn’t assign that object to an object variable.

Looks like the C/AL compiler only wants the ‘connection string’ form…