3

i am using asp.net 2.0 and database is Mysql and i am passing null value using datetime datatype to mysql table like this duedate is datetime

if (ddlTerms.SelectedItem.Text.ToString() != "--Select--")
   {
     DateTime createDate = DateTime.Now.AddDays(Convert.ToDouble(ddlTerms.SelectedValue));
     oInvHeader.DueDate = createDate;
   }
   else
   {
    oInvHeader.DueDate =(how to write the code here)
   }

in invoiceHeader.cs code

using System;
using System.Data;
using MySql.Data.MySqlClient;
using System.Text;

 private DateTime m_DueDate;

public DateTime DueDate
        {
            get
            {
                return m_DueDate;
            }
            set
            {
                m_DueDate = value;
            }
        }

pls help me thank u hemanth

1

3 Answers 3

3

First of all your DueDate property should be nullable to accept a null value.

Then you can assign the null value like..

oInvHeader.DueDate = null;

Here is, how we declare a nullable variable

DateTime? DueDate;
Sign up to request clarification or add additional context in comments.

4 Comments

how to set the datetime poperty is null ( i am asking db r fields in asp.net)
what is this oInvHeader.DueDate ? are you using any code generation tool?
no on dataaccess layer i am using invoiceheader.cs so that class object is oinvHeader and duedate is the datetime datatype
Can you show me that cs file? you can edit your question and paste that cs file code.
0

public virtual Nullable Variablename

it wil take default null

Comments

0
class test
{ 
    public virtual Nullable<Int32> ReagentSupplyCode
     {
        get;
        set;
     }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.