The main problem is that the default execution on a CSpMultiSQL is
'select', not 'insert'.  Plus, you are mixing two sets of commands that
apply to CSpTransaction.

Try something like this:

transaction.begin("DataSourceName");
int result = transaction.executeInsert(do1);
if (result == PROCEED)
{
result = transaction.executeInsert(do2);
}       //if (result == PROCEED)
if (result == PROCEED)
{
transaction.commit();
}       //if (result == PROCEED)
else
{
transaction.rollback();
}       //else

-- Curt Springer
   Team NetDynamics
   Equipe NetDynamics




Eje Thorarinsson wrote:
> 
> Is there someone out there with more experience
> than me explain what could be wrong with the
> following code. I have done this "by the book" in
> ND 4.0 using a SQL Base Databaseserver via ODBC. I
> have 2
> separate dataobjects (MultiSQL) and the darn thing
> always gives me the message "Transaction
> committed..."
> without anything being committed.
> 
> Its getting late here in Sweden, and before I use
> my laptop as a frizbee, I humbly pass on my
> problems to the rest of the world ;-). Many thanks
> for any input!
> 
>  //[[SPIDER_EVENT<btnInsert_onWebEvent>
>  public int btnInsert_onWebEvent(CSpWebEvent
> event)
>  {
>   int command = PROCEED;
> 
>   // Table tb_Users
>   CSpMultiSQL do1 = (CSpMultiSQL)
> CSpider.getDataObject("doUsers");
> 
>   // Table Group_Users
>   CSpMultiSQL do2 = (CSpMultiSQL)
> CSpider.getDataObject("doGroupUser");
>    do2.setValue("dfGroupId",
> getDisplayField("cbGroups").getValue());
>    do2.setValue("dfUserId",
> getDisplayField("txtLoginId").getValue());
> 
>    CSpLog.send(this, CSpLog.CRITICAL, "dfGroupId="
> + getDisplayField("cbGroups").getValue());
>    CSpLog.send(this, CSpLog.CRITICAL, "dfUserId="
> + getDisplayField("txtLoginId").getValue());
> 
>   CSpTransaction transaction = new
> CSpTransaction();
>   try
>   {
>    transaction.addDataObject(do1);
>    transaction.addDataObject(do2);
> 
>    command = transaction.execute();
>    if(transaction.succeeded() && (command !=
> STOP))
>    {
>     // Transaction is commited automatically
>     CSpLog.send(this, CSpLog.CRITICAL,
> "Transaction Successful! Committing.");
>    }
>    else
>    {
>     // Transaction is rolled back automatically
>     CSpLog.send(this, CSpLog.CRITICAL,
> "Transaction Failed! Rolling back.");
>     command = STOP;
> 
>     // Show errorpage
>     pgErrorMsg felSida = (pgErrorMsg)
> CSpider.getPage("pgErrorMsg");
>           felSida.load("Transaction failed! Could
> not Insert into Tables...","Try again..");
>    }
>   }
>   catch(Exception ex)
>   {
>    command = STOP;
>    transaction.rollback();
> 
>    // Show errorpage
>    pgErrorMsg felSida = (pgErrorMsg)
> CSpider.getPage("pgErrorMsg");
>          felSida.load("Internal Transaction
> failure! Could not delete from
> Tables...","Errormessage: " + ex);
>   }
>   return(command);
>  }
>  //]]SPIDER_EVENT<btnInsert_onWebEvent>
> 
>     ---------------------------------------------------------------
> 
>                              Name: vcard.vcf
>             Part 1.2         Type: text/x-vcard
>                          Encoding: 7bit
>                       Description: Card for Eje Thorarinsson

_________________________________________________________________________

For help in using, subscribing, and unsubscribing to the discussion
forums, please go to: http://www.netdynamics.com/support/visitdevfor.html

For dire need help, email: [EMAIL PROTECTED]

Reply via email to