I have a problem with Microsoft ActiveX Data objects 2.7 Library .I want to connect a SQL server database with automation :
Name : ADO.Connection
Type : Automation
SubType : 'Microsoft ActiveX Data Objects 2.7 Library'.Connection
I set the property 'With Events' of this automation to 'yes'.
When i start the programm, Navision execute the instruction ADO.connection.open and stop with error and close the programm !
If i set the property 'With Events' of this automation to 'no', there is no problem but i can not test if the database is correctly open or not ! (I want to test the connection and put the error in an error file).
0
Comments
I hope this helps:)
I traded my sanity for a railgun
When i have this set to no, my code works - i can connect to an external SQL table and do some stuff with it. when i set WithEvents to Yes, however, i get an error when my code reaches the ADOConnection.Open; line of code.
ADOConnection.ConnectionString(STRSUBSTNO(ConnectStr,Provider,"Data Source","Initial Catalog","Integrated Security"));
ADOConnection.Open;
I receive the following error(s):
when i start debugger, i see it throws the error sitting on the WillConnect event. i do not have any code in this trigger.
also, i got the same error when i used ADOConnection.OPEN(connectionstring,user id,password,option) snytax instead of what is shown above.
i wanted to try to use events to set a boolean true after Execute complete. what could i be doing wrong?
The problem is most all of the event triggers from that activex object have parameters of types that have no corresponding type in Navision (hence the error message). I recommend you create your own ActiveX class in VB6 or whatever .NET language (if you prefer) and wrap the functionality you need from the ADO connection class in a Navision safe manner. For instance, you could create your own connection object inside your activex dll that then calls the ADO connection object and passes in the connection string, etc. In the same fashion, within your class you can trap the event from the ADO connection that you are interested in and fire an event of your own creation on your class object. I would rarely recommend using an activex class directly in Navision if it was not constructed with Navision in mind.
I traded my sanity for a railgun
in fact, i am now using ADO quite happily (although in a limited fashion) in NAV . i was investigating the possibility of using the events - i do not need to use them. I can find a happy alternative.
I traded my sanity for a railgun