How to Create UseConnection through Axapta in Ax 2012



The UserConnection class represents an auxiliary connection to the SQL database, based on the same logon properties as the main connection. SQL statements are executed, and results are returned in the context of a UserConnection class. The UserConnection class can be used to obtain a separate transaction scope. 

Create Job and Run it.

static void UserConnection(Args _args)
{
    UserConnection Con;
    Statement Stmt;
    Str sql;
    ResultSet R;
    SqlStatementExecutePermission perm;
 
    Con = new UserConnection();
    sql = 'SELECT * FROM A_PO';
    Stmt = Con.createStatement();
    perm = new SqlStatementExecutePermission(sql);

    // Check for permission to use the statement.
    perm.assert();
    R = Stmt.executeQuery(sql);
    while ( R.next() )
    {
        info(R.getString(1));
    }
}

Related Posts

Previous
Next Post »

Thanks for comments.....