开发者

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)
   }
开发者_JAVA技巧

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


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;


public virtual Nullable Variablename

it wil take default null


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜