代码如下:
dmmanage.ccConnection.Connected:=true; //ccConnectio是dcomconnection.
sDate:='#'+formatdatetime('mm/dd/yyyy',now)+' 00:00:01'+'#';
sDateEnd:='#'+formatdatetime('mm/dd/yyyy hh:nn:ss',now)+'#';
sSql:='select * from customer where (cometime>='+sdate+')'+' and '+'(cometime<='+sDateEnd+')';
dmmanage.cdsmanage.Close;
dmmanage.cdsmanage.CommandText:=sSql;
dmmanage.cdsmanage.Open;出现的错误是:project bathmanage.exe raised exception class EoleException with message '变量或者类型不正确,或者不在可以接受的范围内,要不就是与其他数据冲突。’sdate、sdateend、ssql都是string变量,同样的sql语句在access中是成功的,而程序中确出错,郁闷!!!!!
dmmanage.ccConnection.Connected:=true; //ccConnectio是dcomconnection.
sDate:='#'+formatdatetime('mm/dd/yyyy',now)+' 00:00:01'+'#';
sDateEnd:='#'+formatdatetime('mm/dd/yyyy hh:nn:ss',now)+'#';
sSql:='select * from customer where (cometime>='+sdate+')'+' and '+'(cometime<='+sDateEnd+')';
dmmanage.cdsmanage.Close;
dmmanage.cdsmanage.CommandText:=sSql;
dmmanage.cdsmanage.Open;出现的错误是:project bathmanage.exe raised exception class EoleException with message '变量或者类型不正确,或者不在可以接受的范围内,要不就是与其他数据冲突。’sdate、sdateend、ssql都是string变量,同样的sql语句在access中是成功的,而程序中确出错,郁闷!!!!!
sDateEnd:=formatdatetime('mm/dd/yyyy hh:nn:ss',now);
sSql:='select * from customer where (cometime>='''+sdate+''')'+' and '+'(cometime<=''''+sDateEnd+''')';
注意引号,access里日期型可以用字符串来连接。