开发者

How to force null in date field - access 2007?

开发者 https://www.devze.com 2023-01-15 11:12 出处:网络
I开发者_JS百科 have a table that contains date field. How can I force null or empty value on this field?

I开发者_JS百科 have a table that contains date field.

How can I force null or empty value on this field?

Thanks in advance


I had the same problem and solved it by this:

string DOB = "null" // this solved it , null should be a text and not a value
if(tb_date !="")
 { DOB = "#"+tb_date.text+"#" ;}

//and in the query: insert into table(....,DateofBirth,...) values (.... "',"+DOB+",'"+...) ;


If you are referring to C# code, you can make the type nullable:

DateTime? dt = null;

Then acces it by:

if(dt == null)
  dosomething;
else
  myDT = dt.Value;


It is possible with ADO and a query, amongst other things:

 UPDATE jobs SET atable.adate = Null 
 WHERE atable.ID=342


Just set DBValue.Null whatever field you want to set Null.

0

精彩评论

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