Bang on mukesh g,, running code on server solved the problem ;) Thanks reddy too ...Ya the permission should be outside the caller code.thnks for this valuable info.
On Thu, Mar 5, 2009 at 1:39 PM, sreenath reddy <shysrin...@yahoo.co.in>wrote: > Hi, > > Separate the logic of execution of the execute query in to a different > method. > > Your caller should run on server. For more examples, > you can look at releaseupdateDB classes.Here is the separate static method > for executing the query. > > protected static ResultSet statementExeQuery(str _sql, > Connection _con = null) > { > ResultSet resultSet; > Statement statement; > ; > > try > { > if(!_con) > { > _con = new Connection(); > } > > statement = _con.createStatement(); > > // Do not call assert() here, do it in the caller > // BP deviation documented > resultSet = statement.executeQuery(_sql); > } > catch (Exception::Error) > { > throw error("@SYS99562"); > } > > return resultSet; > } > > Thanks , > Sreenath Reddy > > > > --- On *Wed, 3/4/09, Mukesh Kumar <mukeshmutr...@gmail.com>* wrote: > > > From: Mukesh Kumar <mukeshmutr...@gmail.com> > Subject: Re: [Axapta-Knowledge-Village] Calling SQL Statement thru Axapta > To: Axapta-Knowledge-Village@yahoogroups.com > Date: Wednesday, March 4, 2009, 1:00 PM > > Hi Pankaj, > > Try to do this by using a class and Set the runon property of the > class to Server. > > Regards, > Mukesh > > On Thu, Feb 19, 2009 at 5:44 PM, Pankaj Gupta <pgupt...@gmail. > com<http://mc/compose?to=pgupt...@gmail.com> > > wrote: > >> Hi Guys! >> >> There is one requirement where i need to call a stored procedure of SQL >> Database (SQL Server 2005) from Ax2009. I have copied my requirment to >> simplest example below: During the execution of code it throws these errors >> >> Request for the permission of type 'SqlStatementExecute Permission' >> failed. >> (S)\Classes\ SqlStatementExec utePermission\ demand >> (S)\Classes\ Statement\ executeQuery >> (C)\Jobs\StoredProc edure - line 33 >> >> Cannot select a record in ().The SQL database has issued an error. >> >> ____________ _________ _________ _________ _________ _________ _________ >> _________ _________ _____ >> >> userConnection = new Connection() ; >> stmt = userConnection. createStatement( ); >> >> >> sql = "select %1 from %2 where %3 = %4 and %5 = %6";//'SO-101245'"; >> sql = strfmt(sql, >> ReleaseUpdateDB: :backendFieldNam e(tablenum( >> SalesTable) , fieldnum(SalesTable , custaccount) ), >> ReleaseUpdateDB: :backendTableNam e(tablenum( >> SalesTable) ), >> strfmt(nlslower, ReleaseUpdateDB: :backendFieldNam >> e(tablenum( SalesTable) , fieldnum(SalesTable , SalesId))), >> sqlSystem.sqlLitera l('SO-101245', true), >> strfmt(nlslower, ReleaseUpdateDB: :backendFieldNam >> e(tablenum( SalesTable) , fieldnum(SalesTable , DataAreaId)) ), >> sqlSystem.sqlLitera l(Curext( ),true)); >> >> >> permission = new SqlStatementExecute Permission( sql); >> permission.assert( ); >> >> >> sqlres = stmt.executeQuery( sql); >> CodeAccessPermissio n::revertAssert( ); >> >> sqlres.next( ); >> >> info(sqlres. getString( 1)); >> ____________ _________ _________ _________ _________ _________ _________ >> _________ _________ ___ >> >> Guys I have tried using the LoginProperty class and ODBC connection but no >> avail. Different error came at times but could not login thru Ax2009. My Sql >> server is on another machine and m very much have access rights over that >> machine and SQL Server. >> >> Please help me out , wat m missing ? >> Thnks in advance. >> >> >> >> >> >> >> >> >> >> >> -- >> Pankaj Kumar Gupta >> -- >> Software Developer | MBS Ax. >> Tectura India. - +91 9953559549. >> > > > > -- > Mukesh Mutreja > # 09818421567 > > > > -- Pankaj Kumar Gupta -- Software Developer | MBS Ax. Tectura India. - +91 9953559549.