1.SQL Server 2000时间需要用单引号' '括起来
strsql.Format(_T("select * from INFO where 入库时间 between "));
strsql+=BeginDate.Format( _T("'%Y-%m-%d " ));//sql server中時間需要用單引號''括起來,而access需要##括起來
strsql+=BeginTime.Format( _T("%H:%M:%S '" ));
strsql+=_T(" and ");
strsql+=EndDate.Format( _T("'%Y-%m-%d " ));
strsql+=EndTime.Format( _T("%H:%M:%S '" ));
strsql+=_T(" order by 入库时间 asc ");
2.Access中时间需用双井号# #括起来
str.Format(_T("select * from 节点信息 where 时间 between "));
str+=begindate.Format( _T("#%Y-%m-%d " ));
str+=begintime.Format( _T("%H:%M:%S# " ));
str+=_T(" and ");
str+=enddate.Format( _T("#%Y-%m-%d " ));
str+=endtime.Format( _T("%H:%M:%S# " ));
str+=_T(" order by 时间 asc ");