NAV 2013 ADOConnection

mathieuk
Member Posts: 15
Hi Guys,
Hopefully someone can help me with this.
I'm doing a NAV migration from 2009 to 2013 and there is something I can't make working.
I've got a function that's executing a stored procedure in another SQL database using the following automations:
'Microsoft ActiveX Data Objects 2.8 Library'.Connection
'Microsoft ActiveX Data Objects 2.8 Library'.Command
'Microsoft ActiveX Data Objects 2.8 Library'.Parameter
Then, I've got this code:
IF ISCLEAR(ADOConnection) THEN
CREATE(ADOConnection);
When I try to save the function, it gives me this error:
"You cannot create Automation object "ADOConnection" on NAV server. You must create it on the client computer."
Can't we use automations with NAV 2013?
If not, any other way I can execute a stored procedure from NAV 2013? using DotNet variables?
Cheers
Hopefully someone can help me with this.
I'm doing a NAV migration from 2009 to 2013 and there is something I can't make working.
I've got a function that's executing a stored procedure in another SQL database using the following automations:
'Microsoft ActiveX Data Objects 2.8 Library'.Connection
'Microsoft ActiveX Data Objects 2.8 Library'.Command
'Microsoft ActiveX Data Objects 2.8 Library'.Parameter
Then, I've got this code:
IF ISCLEAR(ADOConnection) THEN
CREATE(ADOConnection);
When I try to save the function, it gives me this error:
"You cannot create Automation object "ADOConnection" on NAV server. You must create it on the client computer."
Can't we use automations with NAV 2013?
If not, any other way I can execute a stored procedure from NAV 2013? using DotNet variables?
Cheers
0
Answers
-
Yes, use
CREATE(ADOConnection,FALSE,TRUE);
If you want to use DotNet variable then try below blog
http://mibuso.com/blogs/ara3n/2011/01/10/using-ado-on-rtc-in-nav/0 -
You can also look at the upgrade toolkit that uses dotnet interop for this.0
-
Thanks guys for your answers.
I'm going to use the DotNet variables as mohana_cse06 suggested.
However, do you know how to add parameters to the SQLCommand?0 -
Hi guys,
I've finally found the solution.
Here is the code, it might help someone else.
L_SQLConnection := L_SQLConnection.SqlConnection(ConnectionString);
L_SQLConnection.Open;
L_SQLCommand := L_SQLCommand.SqlCommand('[dbo].[DeleteUser]',L_SQLConnection);
L_SQLCommand.CommandType := 4; // for a stored proc
L_SQLCommand.Parameters.Add('@ApplicationName','test');
L_SQLCommand.Parameters.Add('@UserName',L_Login."User Id");
L_SQLCommand.ExecuteReader();
L_SQLConnection.Close;
CLEAR(L_SQLCommand);
CLEAR(L_SQLConnection);
Variables
Name DataType Subtype Length
L_SQLConnection DotNet System.Data.SqlClient.SqlConnection.'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
L_SQLCommand DotNet System.Data.SqlClient.SqlCommand.'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Cheers0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions