locked
Stongly typed dataset DBNull error RRS feed

  • Question

  • User-1321503748 posted

    I have a strongly typed dataset that is returning an error when the corresponding field in the database is DBNull. The error I get is:

    System.Data.StrongTypingException was unhandled by user code
      Message="The value for column 'Client_Billing_Contact' in table 'Client' is DBNull."
      Source="App_Code.arfnv1r7"
      StackTrace:
           at slaClient.ClientRow.get_Client_Billing_Contact() in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\slabob\5f562902\4fcd322\App_Code.arfnv1r7.3.vb:line 1662
           at order_orderheader.loadClientData(String clientID) in C:\VS2005\SLABOB\order\orderheader.aspx.vb:line 354
           at order_orderheader.txtClientID_TextChanged(Object sender, EventArgs e) in C:\VS2005\SLABOB\order\orderheader.aspx.vb:line 373
           at System.Web.UI.WebControls.TextBox.OnTextChanged(EventArgs e)
           at System.Web.UI.WebControls.TextBox.RaisePostDataChangedEvent()
           at System.Web.UI.WebControls.TextBox.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent()
           at System.Web.UI.Page.RaiseChangedEvents()
           at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

     I tried to trap the error in the code that binds the field to a textbox, but when I set a breakpoint the error happens before it reaches this code. Checking the error above, it happens in a VS created code file.

     I have searched for this error and found that I am not the only one that has this problem. However none of the solutions work for me. I don't know where/how to check for this error. I tried to trap the error in the VS file when I get the error, but that doesn't work either. Help. Thanks.

    Wednesday, November 1, 2006 9:31 AM

Answers

  • User-1321503748 posted
    Just in case anyone else has this error. I found that in the properties window of the .xsd page there is a setting called NullValue that sets the behavior if one column is Null (you must select a column in the Data Table). Change the setting from Throw Exception to Null or Empty and that will solve the problem.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 19, 2006 5:12 PM

All replies

  • User-1321503748 posted
    Just in case anyone else has this error. I found that in the properties window of the .xsd page there is a setting called NullValue that sets the behavior if one column is Null (you must select a column in the Data Table). Change the setting from Throw Exception to Null or Empty and that will solve the problem.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 19, 2006 5:12 PM
  • User1830192148 posted

    Not quite so. This solution is not available for columns of type System.DateTime, where the only valid option is "(Throw exception)".

    A column "UpdatedDate" is DBNull when a row is first added and will remain so until somebody does an edit.

    Friday, July 1, 2011 10:04 AM