COM connector

Hi, I don’t know if this is the right place to ask this question. I need (in another application then Axapta) information picked from axapta. I googled on the internet and tried the following code, but without success. I get an invalid password if I use AxaptaClass.Logon I get an “System.ArgumentException” when I use Axapta2Class.Logon2 So, nothing seems to work. I’ve checked our licenses. We have 1 license for a COM client. Any suggestions as to how I can get the COM to work? Do I need to set something in Axapta? Do I connect in the wrong way? Someone in my company had the same error, and suggested the COM server of axapta doesn’t function. Any idea’s as to how I can fix this? thx, Kathleen ********************************************** C# code : using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using AxaptaCOMConnector; namespace axaptaConnect { ///

/// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { /// /// Required designer variable. /// private System.ComponentModel.Container components = null; //Combobox for showing the Vendors private System.Windows.Forms.ComboBox Vendors; //Axapta object private AxaptaClass objAxapta = new AxaptaClass(); public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); //Logon to Axapta objAxapta.Logon(“Admin”, “”, “”, “”); //Fill Vendors Combo Getinfo(); //Logoff Axapta LOGOFF(); } public void LOGOFF() { objAxapta.Logoff(); } private void Getinfo() { AxaptaCOMConnector.IAxaptaObject AxaptaQuery,AxaptaQueryRun,AxaptaDataSource; AxaptaCOMConnector.IAxaptaRecord VendTableBuffer; int vendtable = 505; //vendtable ObjID try { AxaptaQuery = objAxapta.CreateObject(“Query”,"","","","","",""); AxaptaDataSource = (IAxaptaObject)AxaptaQuery.Call(“AddDataSource”,vendtable,"","","","",""); AxaptaQueryRun = objAxapta.CreateObject(“QueryRun”,AxaptaQuery,"","","","",""); Vendors.Items.Clear(); while((bool)AxaptaQueryRun.Call(“Next”,"","","","","","")) { VendTableBuffer = (IAxaptaRecord)AxaptaQueryRun.Call(“GetNo”, 1,"","","","",""); Vendors.Items.Add(VendTableBuffer.get_field(“AccountNum”).ToString() + " – " + VendTableBuffer.get_field(“Name”).ToString()); } } catch (Exception ex) { MessageBox.Show(ex.Message); LOGOFF(); } } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.Vendors = new System.Windows.Forms.ComboBox(); this.SuspendLayout(); // // Vendors // this.Vendors.Location = new System.Drawing.Point(8, 8); this.Vendors.Name = “Vendors”; this.Vendors.Size = new System.Drawing.Size(280, 21); this.Vendors.TabIndex = 0; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(292, 266); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.Vendors}); this.Name = “Form1”; this.Text = “Form1”; this.ResumeLayout(false); } #endregion /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new Form1()); } } }

Hi Kathleen, To start with - Has the COM Connector been registered properly? As you may be aware COM Connector can be tested from Internet ->Parameters under Admin → Setup → Internet. Is the test successful? Please let us know. Meanwhile I will also look into this code… Regards, Harish Mohanbabu

Hi, I get a result in dutch. I’ll try to translate it : Result of test of Navision Axapta Business Connector The navision axapta business connector has loaded without problems. Logon on Navision Axapta has succeeded. [Table named System information with information of where everything is located.] All tests have ended without mistakes. The Navision Axapta Business Connector should be ready for use with Navision Axapta.

Have you tried to debug the C# application to find the line where exception is thrown? [^] Is you admin account using same setting as in code you have shown, that is with no password? [:D] My code is also in C#, but is for ASP.NET application the retreives some data from Dimensions table. Here is the sample: ax = new Axapta2Class(); ax.Logon2(“User”,“Pass”,"","","","","",false,"",""); // CREATE QUERY IAxaptaObject axQuery = ax.CreateObject(“Query”,"","","","","",""); IAxaptaObject axDataSource = (IAxaptaObject)axQuery.Call(“AddDataSource”, DimensionsTable,"","","","",""); IAxaptaObject axQueryRun = ax.CreateObject(“QueryRun”, axQuery,"","","","",""); // READ RESULTS while ((bool)axQueryRun.Call(“Next”,"","","","","","")) { string Description, DimensionCode, DimensionNumber; IAxaptaRecord custTableBuffer = (IAxaptaRecord)axQueryRun.Call(“GetNo”, 1,"","","","",""); Description = custTableBuffer.get_field(“Description”).ToString(); DimensionCode = custTableBuffer.get_field(“DimensionCode”).ToString(); DimensionNumber = custTableBuffer.get_field(“Num”).ToString(); }

Hello, The line ax.Logon2(“User”,“Pass”,"","","","","",false,"",""); did the job. I tried the Logon2 before, but I did not use the false. Thx for the help! Kathleen