hmk
hmk

Reputation: 969

how pass the null value using datetime datatype in asp.net and database is mysql?

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

Upvotes: 3

Views: 5772

Answers (3)

Muhammad Akhtar
Muhammad Akhtar

Reputation: 52241

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;

Upvotes: 3

Ajith kumar
Ajith kumar

Reputation: 41

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

Upvotes: 0

Ajith kumar
Ajith kumar

Reputation: 41

public virtual Nullable Variablename

it wil take default null

Upvotes: 0

Related Questions