Combobox giving 'DBNull' error when the first item is choosen


  • I am using combobox to populate values from a table, 'Suppliers'. I put this combobox in a form wherein the order details are filled up. This column 'Supplier' is a Foreign Key and set to NotNull in the order detail table. Selecting the first available entry on the combobox gives error 'SupplierID cant be Null' . Selecting the 2nd value is OK, first choosing 2nd and coming back to 1 is also OK. This error comes up when trying to update the database.

    Even with the first value, the combobox is having a text. I would like to know why the error.
    • Edited by kesk Monday, October 05, 2009 10:01 AM update
    • Changed type kesk Monday, October 05, 2009 10:58 AM from discussion to ?
    Monday, October 05, 2009 10:00 AM

All replies

  • Hi kesk,

    Is this a question or a discussion, I see nothing to discuss about?
    Monday, October 05, 2009 10:02 AM
  • Its a discussion, sorry if i was not clear.

    I choose the first available option on the combobox, enter other values in the form. Now I try to update the database, but this gives error as reported. Why is the error coming ? thats my question.
    Monday, October 05, 2009 10:35 AM
  • Then choise it to question, it shows now up as a discussion.

    But giving an answer is very difficult. Is the only reply you get Supplier ID cant be Null, I doubt it because this text I've never seen.

    If you have an error give at least the complete text from that.

    Monday, October 05, 2009 10:39 AM
  • Again, my mistake.

    I am trying to design a Inventory program and the table designs are somewhat like Northwind database. Here the SupplierID is a colmn and not a literal meaning. The table Suppliers holds the details of the Suppliers, where the SupplierID is the primary key. In another table,  SupplyOrders, I have SupplierID as FK.

    When a new order is to be added, i present the SupplierID in a combobox. When loading the form, i populate the combobox from Suppliers table. It shows the values. At present, the supplier table has only 2 rows of data.

    Now in the OderDetail form, when i choose the first available entry only, i cant update the database. Choosing the 2nd , i can update the db. Choosing the 2nd and coming back to the first also is OK.

    My question why choosing the first available entry in combo gives error. ? Since there is no 'Default' value for the combobox, i cant set that also. Why cant I choose the first?
    Monday, October 05, 2009 10:58 AM
  • For me it is still not clear what you do, but if you can provide the code that populates the combobox, then maybe it becomes a little bit visible for us.

    A combobox has many combinations in which it can be populated.

    Monday, October 05, 2009 11:10 AM