How can i read data from Sql Server Axapta Database tables from X++ without ODBC connection?
I don’t want to create the ODBC in all the clients , so I want to access the Sql Server database from X++
without any other dependencies.
You may use Connection class. By default this will establish a connection to the current database session. Code snippet from Developers guide below. Also search in this forum as this subject was already discussed.
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();
}
I am calling stored procedure using connection class nd using executeupdate to execute the stored procedure.In my stored procedure I am calling the view of another database and have full rights on another database. looks like sql connection is timing out and inserting very few records than expected. Same stored procedure with same rights inserts more records when called from sql server.is there any way to increase the query timeout of sql connection