Object can not be cast from the DBNull to the other type errors

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 10533
    New Member
    • Mar 2010
    • 3

    Object can not be cast from the DBNull to the other type errors

    HI,

    There are 2tables in the "mydatabse" .

    1. Tools
    2. ToolsRepair

    there are some columns in the above two tables.

    Toolid is the primary key of the Tools table and also FK for the ToolsRepair
    and also there are some other columns in the two tables

    I am trying to insert the all details of the ToolsRepair table using that FK_ Toolid

    but I am getting the error,

    Cannot insert the value NULL into column 'Tool_id', table 'ToolApp.dbo.To olsRepair'; column does not allow nulls. INSERT fails. The statement has been terminated.

    please help me out...
    thanks in advance
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    The table doesn't allow nulls. You want to use a null. What advice do you want? The table won't allow it. Put in something else.

    Comment

    • 10533
      New Member
      • Mar 2010
      • 3

      #3
      Thank you, thats I understand, am new to C sharp coding

      SO could you please explain me more clearly??

      thanks.

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        No. I don't think I could be any more clear than that.

        If the table doesn't allow nulls, then you can't force it to accept them.

        Database How-to parts 1 and 2
        Database tutorial Part 1
        Database tutorial Part 2

        Comment

        Working...