This is some Code I made to test the Connection in c#, it calls a static
class method a couple times and writes the output to the console,  then
executes a query and writes output of the name field from the custTable
to the console as well. Then it calls another static method that does
the same query in x++.  Hope it gives you some ideas.

-Preston

// project created on 3/15/2004 at 1:28 PM
using System;
using System.Configuration;

class MainClass
{
            public static void Main(string[] args)
            {
                        string accountNumber;
                        string test;
                       
                        Console.WriteLine("Axapta Com Test");
                        try{
                                    axDLL.IAxapta2 axapta = new
axDLL.Axapta2();
                                   
                                    axapta.Logon2("com","com","dmo","",
"", "", "ax30", null, null, null);
                                    //axapta.Logon(
                                    axapta.Refresh();

Console.WriteLine(axapta.CallStaticClassMethod("plTest",
"testMethod",null,null,null,null,null,null));

Console.WriteLine(axapta.CallStaticClassMethod("plTest",
"testMethod",null,null,null,null,null,null));
                                    Console.WriteLine("EX {0}",
axapta.CallStaticClassMethodEx("plTest", "testMethod",null));
                                   
                                    axDLL.IAxaptaObject axq =
axapta.CreateObjectEx("Query", null);
                                    axDLL.AxaptaParameterList axParmList
= new axDLL.AxaptaParameterList();
                                    axParmList.Size = 1;
                                    axParmList.set_Element(1,77); //77 =
custTable ID
                                    axq.CallEx("AddDataSource",
axParmList);
                                    axParmList.set_Element(1, axq);
                                    axDLL.IAxaptaObject axQR =
axapta.CreateObjectEx("QueryRun", axParmList);   
                                   
                                    axDLL.IAxaptaRecord axBuff;
                                    test = "scrTop";
                                    test =
ConfigurationSettings.AppSettings.Get(test);
                                    Console.WriteLine(test);

while((bool)axQR.CallEx("Next",null)){
                                               

axParmList.set_Element(1, 1);
                                                axBuff =
(axDLL.IAxaptaRecord)axQR.CallEx("GetNo", axParmList);
                                                accountNumber =
axBuff.get_field("AccountNum").ToString();

Console.WriteLine(accountNumber);
                                    }
                                   
                                    axParmList.set_Element(1, "4000");
                                    axBuff =
(axDLL.IAxaptaRecord)axapta.CallStaticRecordMethodEx("custTable","find",
axParmList);
                                   

Console.WriteLine(axBuff.get_field("Name").ToString());
                                   
                                   

Console.WriteLine(((axDLL.IAxaptaRecord)axapta.

CallStaticClassMethod("plTest","find", "4000",

null,null,null,null,null)).

get_field("Name").ToString());
                                   
                                    //axBuff = null;
                                    //axParmList = null;
                                    //axapta.Stop();
                                   
                        }
                        catch(Exception e){
                                    Console.WriteLine("{0} Exception
caught.", e);
           
                        }

            }
}



-----Original Message-----
From: gunnark75 [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 08, 2004 9:47 AM
To: [EMAIL PROTECTED]
Subject: [development-axapta] C#


Hi, i'll try to call an Axapta Job from a C# Programm.
VB6 works. Could some one give me tip, or short example ?

thx


<http://us.adserver.yahoo.com/l?M=298184.5022502.6152625.3001176/D=group
s/S=:HM/A=2164339/rand=798466968>

  _____ 

Yahoo! Groups Links
*         To visit your group on the web, go to:
http://groups.yahoo.com/group/development-axapta/
 
*         To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]
be>
 
*         Your use of Yahoo! Groups is subject to the Yahoo! Terms of
<http://docs.yahoo.com/info/terms/>  Service.


[Non-text portions of this message have been removed]



Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links

Reply via email to