虽然字段允许为空,但插入一个空字符串时,SysBase数据库给的是一个默认的1900-01-01 00:00:00
这个有点烦人,本来这个时间值得作用是控制本条数据的作用时间,开始时间和结束时间,如果空值代表任何时间有效。如果任其默认值得插入,在前台会增加取数据的负担。只好在后台处理。
处理的方法一
strCmd = "update  employees set name='"+strName+ (CheckDateTime(strBegin)?("',begin_='"+strBegin:"")+ 
(CheckDateTime(strEnd)?("',end_='"+strEnd:"")+
" where EmployeeID='"+strEmployeeID+"'";private static bool CheckDateTime(string source)
{
      return source == "";
}处理方法二
string strCmd = "update employees set ";
if (strBegin!= "" || strBegin != null)
strCmd += " begin='"+strBegin +"',";
if (strEnd != ""    || strEnd  != null)
strCmd += " end='"+strEnd +"',";
strCmd +=" where EmployeeID='"+strEmployeeID+"'";这样的问题,似乎在以前,组合查询的时候遇到过,也是要对where条件进行拼T-SQL语句。
各位有什么好的见解么。说来听听