I am having a problem with the ADO command object. The ADO Objects 2.6 library command ActiveConnection property is expecting a boolean so I can’t assign either a connection or Connection string. If I use a Connection object with a Recordset object then I can access the data fine. Any suggestions?
ActiveConnection property is defined as Connection. You probably forgot to use the Set command such as: Set cmd.ActiveConnection = Conn I did check ADO 2.5, 2.6, and 2.7 type library in VB’s Project–>References. View–>Object Browser shows the data type for each property. All point to Connection.
Thanks for the answer. This is in C/AL so there is no set. In visual basic it works fine. In fact this is the strange thing if I look in the object browser in VB the ActiveConnection property is of type connection. In Navision if you declare both an ADODB.Recordset and ADODB.Command as global variables of type automation then have a look in the C/Al symbol menu then the the ActiveConnection property on a Recordset is a connection and the ActiveConnection property on the Command is a boolean. As an example: 3 Global variables of type automation: autConn ‘Microsoft ACtiveX Data Objects 2.6 Library’.Connection autRS ‘Microsoft ACtiveX Data Objects 2.6 Library’.Recordset autCmd ‘Microsoft ACtiveX Data Objects 2.6 Library’.Command CREATE(autConn); autConn.ConnectionString := ConnectionString; autConn.Cursorlocation := 3; autConn.Open CREATE(autRS); autRS.ActiveConnection := autConn; //This works fine. Create(autCmd) autCmd.ActiveConnection := autConn; //Can’t do this as type conversion error Boolean = Automation This is a simple example but illustrates the problem.
See here for a similar question: http://www.mbsonline.org/forum/topic.asp?TOPIC_ID=1049 Also: http://www.mbsonline.org/forum/topic.asp?TOPIC_ID=5790 http://www.mbsonline.org/forum/topic.asp?TOPIC_ID=3582 Try searching the forum for “ADO Command” or “ADO Access”…
quote:
This is the exact same problem as I’m having, however I still get the same error even if I follow the solution line by line. I am only having the problem with the ADODB.Command object. I just can’t see why is is expecting a datatype boolean.
I’ve done a little more investigation. With ADO 2.5 and below the command.activeconnection property is expecting a string and this works fine if you provide a valid connection string. With ADO 2.6, 2.7 and 2.8 the property is boolean.
You may try: adoConnection.Execute(‘exec myproc’); this works fine
This problem can be solved if you declared the variable var_aConnection as variant var_aConnection:= aConnection; aCommand.ActiveConnection := var_aConnection; // By this way program will be compiling and will be work !!!