Error message when inserting null value

Posts   
 
    
MikeM
User
Posts: 7
Joined: 08-Dec-2004
# Posted on: 08-Dec-2004 17:59:52   

Hi,

This is my first time on the forum, but I've read a few of the threads.

As is the case with most large organisations I've been given a project with tight timescales to deliver as soon as possible using ASP .NET and utilising LLBGEN software to access an Oracle database, except for the Oracle database, I don't know any of the other software. I've been in the software development business for over 25 years, mainly 3gl type languages and I've been given no training or manuals and have been told to get on with it!! Situation normal.

I've managed to get going and have generated a number of web pages and the LLBGEN stuff works fine. except for the following problem.

I'm inserting a user details record into a table and some of the fields can be null. When I come to save() the record, it stores the record on the database correctly but also gives an error message. This error message is not there when all the fields are populated.

Error Message 'An exception was caught during the execution of an action query: Value cannot be null. Parameter name: value. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.'

Only the USER_SURNAME is a NOT NULL field

        

If e.CommandName = "AddNewRow" Then
  _Entity = New FGFM.EntityClasses.USR_DETAILSEntity
     With (_Entity)
        
        .USER_SURNAME = Convert.ToString(CType(e.Item.FindControl"txtSurnameF"),
TextBox).Text)
        
         .USER_NAME = Convert.ToString(CType(e.Item.FindControl("txtNameF"), TextBox).Text)
        
         ein = Convert.ToString(CType(e.Item.FindControl("txtEinF"), TextBox).Text)
         If ein <> "" Then
              .USER_EIN = Convert.ToDecimal(CType(e.Item.FindControl("txtEinF"), TextBox).Text)
          End If
        
          .USER_TEL = Convert.ToString(CType(e.Item.FindControl("txtUserTelF"), TextBox).Text)
          .USER_TITLE = Convert.ToString(CType(e.Item.FindControl("txtTitleF"), TextBox).Text)

           Try
               .Save()
                SetErrorMessage("")
                Catch ex As Exception
                    'Set error message
                    SetErrorMessage(Convert.ToString(ex.Message))
                     transactionManager.Rollback()
                Finally
                    ' clean up. Necessary action.
                    transactionManager.Dispose()
                End Try
 end if

Hope you can make sense of the code.

Thanks

Mike

PS. I've put a bit of 3gl code to get around the problem of the EIN field which was giving me grief because it was trying to convert a null value in the text field to an integer. I'm sure that there is an elegant way of doing it, but I just don't have the time to find out how!!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 08-Dec-2004 18:38:18   

If the value you're trying to set in .USER_SURNAME exceeds the max. length of that field, it will not be set, and .USER_SURNAME will thus result in NULL.

Could you check that for me, please? Also, the ODP.NET provider sometimes gives weird errors: Value cannot be null, while the error is something completely different.

Other question: what's the PK field, is it sequenced? (i.e. do you need a sequence value for the PK?)

Frans Bouma | Lead developer LLBLGen Pro
MikeM
User
Posts: 7
Joined: 08-Dec-2004
# Posted on: 09-Dec-2004 10:30:39   

The length of the USER_SURNAME is not an issue, it is within max length of the field. The PK is an integer and is populated via a trigger on the Oracle database.

The record is stored correctly but the error message still appears.

I can work around it, it's just a bit annoying.

This is the USR_DETAILS record


 USER_SURNAME                 NOT NULL VARCHAR2(30)
 USER_NAME                                       VARCHAR2(30)
 USER_TITLE                                      VARCHAR2(10)
 USER_TEL                                          VARCHAR2(15)
 USER_TYPE                                        VARCHAR2(15)
 ACCESS_LEVEL                                      NUMBER(11)
 LAST_ACCESS                                        DATE
 LAST_USED_FILTER                                  VARCHAR2(35)
 LAST_USED_SEARCH                                  VARCHAR2(35)
 USER_ID                                   NOT NULL NUMBER (PK)
 MAX_TRAVEL_DISTANCE                                NUMBER
 WORKGROUP                                        NUMBER
 ADDRESS1                                          VARCHAR2(50)
 ADDRESS2                                          VARCHAR2(50)
 ADDRESS3                                          VARCHAR2(50)
 ADDRESS4                                          VARCHAR2(50)
 POSTCODE                                          VARCHAR2(10)
 EMAIL_ADDRESS                                    VARCHAR2(50)
 MOBILE_NO                                        VARCHAR2(15)
 USER_EIN                                          NUMBER

Thanks

Mike

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 09-Dec-2004 10:44:48   

I think the trigger is the issue. The new PK value is unkown after the row is written. If the trigger sets the PK using a sequence, set up the PK field with the sequence in the designer and drop the trigger.

Frans Bouma | Lead developer LLBLGen Pro
MikeM
User
Posts: 7
Joined: 08-Dec-2004
# Posted on: 09-Dec-2004 14:03:17   

Disabled the trigger on the database and it worked!

Thanks a lot

Mike