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. General Programming
  3. LINQ
  4. LINQ update with NULL value.

LINQ update with NULL value.

Scheduled Pinned Locked Moved LINQ
csharplinqhelpquestionannouncement
3 Posts 2 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.
  • M Offline
    M Offline
    Maxy55
    wrote on last edited by
    #1

    Hi All, I am getting a problem when i try to update a datetime field with null value,I don't have any problem in while inserting a NULL value or updating with an another datetime value.I am getting this problem only while updating the datetime field with null values and i am using DBML. As i am new to linq concepts.I have used the following line of code. DateTime? Date = txtEnd.Text == string.Empty ? (DateTime?)null : Convert.ToDateTime(txtEnd.Text); Thanks, maxy.

    I 1 Reply Last reply
    0
    • M Maxy55

      Hi All, I am getting a problem when i try to update a datetime field with null value,I don't have any problem in while inserting a NULL value or updating with an another datetime value.I am getting this problem only while updating the datetime field with null values and i am using DBML. As i am new to linq concepts.I have used the following line of code. DateTime? Date = txtEnd.Text == string.Empty ? (DateTime?)null : Convert.ToDateTime(txtEnd.Text); Thanks, maxy.

      I Offline
      I Offline
      Ian McCaul
      wrote on last edited by
      #2

      The problem you are having isn't really a linq problem but deals with nullable types. When setting a nullable type to null you do not need to cast. Try this DateTime? Date = txtEnd.Text == string.Emtpy ? null : Convert.ToDateTime(txtEnd.Text);

      M 1 Reply Last reply
      0
      • I Ian McCaul

        The problem you are having isn't really a linq problem but deals with nullable types. When setting a nullable type to null you do not need to cast. Try this DateTime? Date = txtEnd.Text == string.Emtpy ? null : Convert.ToDateTime(txtEnd.Text);

        M Offline
        M Offline
        Maxy55
        wrote on last edited by
        #3

        Hey mac thanks for the reply man.I tried both ways yaar,if the problem was with my Nullable types then it should not even insert NULL Datetime values with the same function i used.Any ways thanks for the reply and even if you get any solution please post it. Thanks, maxy

        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