commit action to insert and to update
hello,
i m using adf afces 11g and MS SQL server 2005 as database,
in my form i m using a commit button that run two action for the same click.
action 1 : fill the id text field if it's empty.
action 2 : commit the the information in the database.
this is the code of the binding method of my commit button :
*public String cb1_action3() throws NamingException, SQLException, ClassNotFoundException {*
*if(it1.getValue()==null){*
Connection connection = ConnectionManager.getInstance().getConnection();
Statement statement = connection.createStatement();
ResultSet resultSet=statement.executeQuery("SELECT max(id) FROM spider");
while(resultSet.next())
*{*
it1.setValue(resultSet.getInt(1)+1);
*}*
BindingContainer bindings = getBindings();
OperationBinding operationBinding = bindings.getOperationBinding("Commit");
Object result = operationBinding.execute();
*/* if (!operationBinding.getErrors().isEmpty()) {*
return null;
*}*/*
*}*
*else {*
BindingContainer bindings2 = getBindings();
OperationBinding operationBinding2 = bindings2.getOperationBinding("Commit");
Object result = operationBinding2.execute();
*if (!operationBinding2.getErrors().isEmpty()) {*
return null;
*}*
*}*
return null;
*}*
N.B: it1 is the binding variable of my id text field.
every thing is working fine, the id code is generated and the row is commited in the database, but when i try to edit the same record by the form, an error message says that the INDENTITY_INSERT of the table is turned off.
on my database i run this "set IDENTITY_INSERT spider ON" but the problem is still here.
i need your help.
thank you.