Store "Null" to Date/Time datatype in Access

Discussion in 'ASP.NET / ASP.NET Core' started by calvin, Aug 19, 2004.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I want to update a Date/Time datatype in MS Access by Null value(or blank?). A variable is declare as DateTime datatype in ASP.NET. I was use the following approach try to set null/empty.

    Dim TimeIn as DateTime
    TimeIn = New DateTime <<------ What should i change here??

    'Update Statement here'
    ...
    ...
    cmdUpdate.Parameters.Add("@TimeIn", TimeIn)
    ...


    After update the DB, all the column which store TimeIn contain a value 01-01-2001, this is not what i want. I want it is "Totally nothing(null/empty)" in the column. When I bind the TimeIn to the datagrid, it will show "12:00:00 AM "

    Is anyone know to solve it.Thank you

    Calvin
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    Why not just not update or insert that field and set the database field to allow null?



    quote:Originally posted by calvin

    I want to update a Date/Time datatype in MS Access by Null value(or blank?). A variable is declare as DateTime datatype in ASP.NET. I was use the following approach try to set null/empty.

    Dim TimeIn as DateTime
    TimeIn = New DateTime <<------ What should i change here??

    'Update Statement here'
    ...
    ...
    cmdUpdate.Parameters.Add("@TimeIn", TimeIn)
    ...


    After update the DB, all the column which store TimeIn contain a value 01-01-2001, this is not what i want. I want it is "Totally nothing(null/empty)" in the column. When I bind the TimeIn to the datagrid, it will show "12:00:00 AM "

    Is anyone know to solve it.Thank you

    Calvin
    </blockquote id="quote"></font id="quote">

    B.

    DiscountASP.NET
    http://www.DiscountASP.NET
     
  3. I don't have the possibility to test it at the moment, but what is when you set the value DBNull (System.DBNull) instead of TimeIn in cmdUpdate.Parameters.Add?
     
  4. If the row contain the value(TimeIn), and i need to "remove" it by set to null or blank.
     
  5. quote:Originally posted by calvin

    If the row contain the value(TimeIn), and i need to "remove" it by set to null or blank.
    </blockquote id="quote"></font id="quote">
    Yes, but the value null is in every row equal, doesn't this function?:

    cmdUpdate.Parameters.Add("@TimeIn", DBNull.Value)
     
  6. It is works, thank you

    calvin
     
  7. well, this post started as a 'HELP! I'm having a similar problem!' and evolved into 'FYI' ;-) ... so, FYI:

    if you are in a situation (like I am) where you are using a DataSet as an intermediate data store, and you can't manipulate/modify your sql command parms directly at update time, the DataSet class provides a mechanism to deal with this problem: DataRow.Set[ColumnName]Null!

    seems obvious... now!
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page