Thank You. But I still get an error. when the class is set to 'server' I get this error:
[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'Domain\AOSSever$'. and if I set the class to 'client': ODBC operation failed. LoginProperty must be instantiated on same tier as OdbcConnection. Do I need to set permissions? thanks Brian --- In [email protected], "palleagermark" <[EMAIL PROTECTED]> wrote: > > In 4.0 no client is supposed to access the database directly. Only > the AOS can do that, and as such code like this will have to access > the database in the security context of the user which the AOS runs. > > Following code will work: > ODBCConnection connection; > SqlSystem sqlSystem = new SqlSystem(); > LoginProperty loginProperty = > sqlSystem.createLoginProperty(); > Statement statement; > ResultSet resultSet; > SqlStatementExecutePermission sqlStatementExecutePermission; > str sqlStatement; > ; > > loginProperty = sqlSystem.createLoginProperty(); > loginProperty.setServer('MyServer'); > loginProperty.setDatabase('MyDatabase'); > > connection = new ODBCConnection(loginProperty); > > statement = connection.createStatement(); > > sqlStatement = "select * from MyTable"; > sqlStatementExecutePermission = new SqlStatementExecutePermission > (sqlStatement); > > sqlStatementExecutePermission.assert(); > > resultSet = statement.executeQuery(sqlStatement); > > > Regards, > Palle Agermark > > --- In [email protected], "branjema" <branjema@> > wrote: > > > > Hi I have a problem with the following code below. I tried > creating > > the DSN on the server and setting the class to runon = 'server' > > > > but it cannot find the DSN. > > > > question 1: must I set up the DSN on all client machines? > > > > > > > > also I tried these lines of code: > > > > > > //loginProperty.setUsername(""); // user name > > //loginProperty.setDatabase(''); // database name > > //loginProperty.setServer(""); // SERVER name > > > > > > but i get an error message stating that these properties are no > > longer supported. > > > > the problem is I need to retrieve data from another server to run a > > report. > > > > can anyone help? > > > > Thanks in advance > > > > b > > > > > > > > ODBCConnection oDBCConnection; > > LoginProperty loginProperty; > > Statement statement; > > ResultSet r; > > str strTest; > > > > > > ; > > > > > > > > > > // Initialize Connection > > loginProperty = new LoginProperty(); > > loginProperty.setDSN('test'); // DSN Name > > > > > > > > //loginProperty.setUsername(""); // user name > > //loginProperty.setDatabase(''); // database name > > //loginProperty.setServer(""); // SERVER name > > > > //loginProperty.setPassword(""); // password > > > > // Create Connection Object > > > > ODBCConnection = new ODBCConnection(loginProperty); > > statement = oDBCConnection.createStatement(); > > > > // Execute update Query > > r = statement.executeQuery("SELECT * from table); // > > > > while (r.next()) > > > > strTest = r.getString(2) ; > > > > > > return r.getString(1); > > >

