Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Cannot insert NULL in DB where datatype is DateTime

Cannot insert NULL in DB where datatype is DateTime

Scheduled Pinned Locked Moved ASP.NET
databasesql-serversysadminhelp
9 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rhtbhegade
    wrote on last edited by
    #1

    Hi Experts, i want to insert NULL in DB where my datatype is DateTime, as its not Compulsary Field... But I could not do so.... m using MS SQL Server 2005 Please Help

    Sharing Of Knowledge Provides Solution....

    S L D A A 5 Replies Last reply
    0
    • R rhtbhegade

      Hi Experts, i want to insert NULL in DB where my datatype is DateTime, as its not Compulsary Field... But I could not do so.... m using MS SQL Server 2005 Please Help

      Sharing Of Knowledge Provides Solution....

      S Offline
      S Offline
      Sagar H Mistry
      wrote on last edited by
      #2

      can you please send me your query and table script

      R 1 Reply Last reply
      0
      • S Sagar H Mistry

        can you please send me your query and table script

        R Offline
        R Offline
        rhtbhegade
        wrote on last edited by
        #3

        Can u Please tell me how to send script of table.. m a fresher i have seen options in SQL such as script table as-> create drop select insert update delete which 1 to use to give u.

        Sharing Of Knowledge Provides Solution....

        1 Reply Last reply
        0
        • R rhtbhegade

          Hi Experts, i want to insert NULL in DB where my datatype is DateTime, as its not Compulsary Field... But I could not do so.... m using MS SQL Server 2005 Please Help

          Sharing Of Knowledge Provides Solution....

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Hi All, check ur setting of a column i think in ur setting make Allow null = true; Thanks and regards, Amit Patel

          1 Reply Last reply
          0
          • R rhtbhegade

            Hi Experts, i want to insert NULL in DB where my datatype is DateTime, as its not Compulsary Field... But I could not do so.... m using MS SQL Server 2005 Please Help

            Sharing Of Knowledge Provides Solution....

            D Offline
            D Offline
            dan sh
            wrote on last edited by
            #5

            rhtbhegade wrote:

            But I could not do so....

            Why? Where exactly are you stuck?

            50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

            1 Reply Last reply
            0
            • R rhtbhegade

              Hi Experts, i want to insert NULL in DB where my datatype is DateTime, as its not Compulsary Field... But I could not do so.... m using MS SQL Server 2005 Please Help

              Sharing Of Knowledge Provides Solution....

              A Offline
              A Offline
              Abhishek Sur
              wrote on last edited by
              #6

              What about DbNull.Value ?

              Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


              My Latest Articles-->** Simplify Code Using NDepend
              Basics of Bing Search API using .NET
              Microsoft Bing MAP using Javascript

              1 Reply Last reply
              0
              • R rhtbhegade

                Hi Experts, i want to insert NULL in DB where my datatype is DateTime, as its not Compulsary Field... But I could not do so.... m using MS SQL Server 2005 Please Help

                Sharing Of Knowledge Provides Solution....

                A Offline
                A Offline
                Ashfield
                wrote on last edited by
                #7

                The most obvious reason is your data table does not allow nulls in that column. Other than that there is no reason why you can't do it, as long as the rest of your code is correct - unfortunately I can't see your code from here to tell, and you have not even given us the error message that you trapped - you did trap it of course?

                Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

                S 1 Reply Last reply
                0
                • A Ashfield

                  The most obvious reason is your data table does not allow nulls in that column. Other than that there is no reason why you can't do it, as long as the rest of your code is correct - unfortunately I can't see your code from here to tell, and you have not even given us the error message that you trapped - you did trap it of course?

                  Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

                  S Offline
                  S Offline
                  Sathiyaraj Ganesan
                  wrote on last edited by
                  #8

                  Hi, Have a look at this post here

                  Sathiya

                  A 1 Reply Last reply
                  0
                  • S Sathiyaraj Ganesan

                    Hi, Have a look at this post here

                    Sathiya

                    A Offline
                    A Offline
                    Ashfield
                    wrote on last edited by
                    #9

                    Think you meant to reply to the original post as thats exactly what I said, its perfectly possible to insert nulls to a datetime column if you do it properly :)

                    Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups