Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2010
    Posts
    8

    Unanswered: ERROR_MESSAGE() doesnot return column name to UI

    I want to my sql query to return the column name which fired the exception along with the reason to UI.

    when I use ERROR_MESSAGE() it returns only
    Code:
    Server: Msg 515, Level 16, State 2, Line 3
    instead of

    Code:
    Server: Msg 515, Level 16, State 2, Line 3
    Cannot insert the value NULL into column 'a', table
    'tempdb.dbo.notnull'; column does not allow nulls. INSERT fails.
    The statement has been terminated.
    @@error is 0.
    Can some one help. This is urgent.

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Which UI ?

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Sep 2010
    Posts
    8

    .Net UI

    I am using windows application in .Net. In that UI only 1st line is displayed instead of entire text. We are not able to send the entire problem to UI

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    That's a common problem with .NET controls. Odds are good that the data is fine, but the UI is monkeyed up. Make sure that the control height is large enough for multiple lines, and that the Rich Text attribute is non-zero.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  5. #5
    Join Date
    Sep 2010
    Posts
    8

    error to be displayed in grid

    Hi Pat,

    Requirement is to display the data in grid.

  6. #6
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    The problem lies in the .NET table control. It can't cope with formatting characters like TAB, CR, and LF in the raw data stream. Try using a gridView instead. I've found them much more flexible.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  7. #7
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    \r\n != <br />
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  8. #8
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    If you use a stored procedure, then you should get the error back:
    Code:
    create table dbo.t1(f1 int not null)
    go
    begin try
       insert dbo.t1(f1) values (null)
    end try
    begin catch
       declare @err nvarchar(max)=error_message()
       raiserror ('%s', 0, 1, @err)
    end catch
    go
    
    Last edited by rdjabarov; 12-09-10 at 17:15. Reason: formatting
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •