Save Entity

Posts   
 
    
shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 18-Jun-2010 09:17:09   

LLBLGen 3.0 .Net Framework 2.0 Oracle 9i

Hello Support, In my code below, accountnature.Description = ClubCentricBISpecific.ChangeCase.ToTitleCase(tbxdescription.Text.Trim()); is a mandatory field in database. I am just trying to return error message that data is not saved when user has entered this field. Example

#region Fileds mapped between database tablename.columnname and GUI

        accountnature.Description = ClubCentricBISpecific.ChangeCase.ToTitleCase(tbxdescription.Text.Trim());
        accountnature.Createddate = ClubCentricBISpecific.ServerDateTime.getcurrentserverdatewithtime();
        accountnature.CreateduserId = ClubCentricBISpecific.StandardMessage.loginuserid;

        #endregion

        #region Insert Data

        bool succeeded = adapteraccountnature.SaveEntity(accountnature, true);

        if (succeeded)
        {
            message = ClubCentricBISpecific.StandardMessage.datasavesuccess; // Get message if data is saved successfully
            MessageBox.Show(message); // Display Message
            adapteraccountnature.CloseConnection();
            DoRefresh(); //call
        }
        else
        {
            message = ClubCentricBISpecific.StandardMessage.datasavefailure; // Get message if data is not saved
            adapteraccountnature.CloseConnection();
            MessageBox.Show(message); // Display Message
        }

        #endregion 

But the code halts at bool succeeded = adapteraccountnature.SaveEntity(accountnature, true);

My question is why is it not going to else part ? since saveentity becomes false

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 18-Jun-2010 09:40:16   

I am just trying to return error message that data is not saved when user has entered this field. Example

You mean when user doesn't enter a value for this field.

But the code halts at bool succeeded = adapteraccountnature.SaveEntity(accountnature, true)

When inserting a row and there is no value for a mandatory field, the database throws an error and the database provider throws an exception back to you. So you should handle the exception in this case.

LLBLGen Pro Framework doesn't swallow exceptions, otherwise you won't know what was the reason of the error.

shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 18-Jun-2010 09:58:35   

Walaa wrote:

I am just trying to return error message that data is not saved when user has entered this field. Example

You mean when user doesn't enter a value for this field.

But the code halts at bool succeeded = adapteraccountnature.SaveEntity(accountnature, true)

When inserting a row and there is no value for a mandatory field, the database throws an error and the database provider throws an exception back to you. So you should handle the exception in this case.

LLBLGen Pro Framework doesn't swallow exceptions, otherwise you won't know what was the reason of the error.

Ok Thanks