Lounge - Axapta 4.0 database connectivity - Asked By anurag gupta on 20-Oct-11 07:33 AM

hello everyone ,

can anybody tell how can we connect external sql server database in Axapta 4.0 to access the tables
TSN ... replied to anurag gupta on 20-Oct-11 07:40 AM
hi...

try like below..

You may use Connection class. By default this will establish a connection to the current database session. Code snippet from Developers guide below.

server static void main(Args args)
{
    Connection con = new Connection();
    Statement stmt = con.createStatement();
    ResultSet r;
    str sql;
    SqlStatementExecutePermission perm;
    ;
 
    sql = strfmt('SELECT VALUE FROM SQLSYSTEMVARIABLES');
 
    // Set code access permission to help protect the use of
    // Statement.executeUpdate.
    perm = new SqlStatementExecutePermission(sql);
    perm.assert();
 
    try
    {
        r = stmt.executeQuery(sql);
        while (r.next())
        {
            print r.getString(1);
            pause;
        }
    }
    catch (exception::Error)
    {
        print "An error occured in the query.";
        pause;
    }
    // Code access permission scope ends here.
    CodeAccessPermission::revertAssert();
}


for reference...

http://dynamicsuser.net/forums/p/43092/218217.aspx
anurag gupta replied to TSN ... on 21-Oct-11 01:08 AM
Thanks
Asked By anurag gupta on 21-Oct-11 01:09 AM
Thanks