| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 632 人关注过本帖
标题:[求助]关于查询中date与string类型数据转换中的问题!
只看楼主 加入收藏
zzx1213
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-8-7
收藏
 问题点数:0 回复次数:0 
[求助]关于查询中date与string类型数据转换中的问题!

我做了一个多重查询的程序.表内数据有string和date类型,

//操作员
if isnull(ls_czy) or ls_czy = '' then
ls_where =ls_where
else
if ls_where ='' or isnull(ls_where) then
ls_where = "gg_cpzl.czy like'" + ls_czy + "%'"
else
ls_where =ls_where + "and " + "gg_cpzl.czy like'" + ls_czy + "'"
end if
end if
//类别
if isnull(ls_lb) or ls_lb = '' then
ls_where =ls_where
else
if ls_where ='' or isnull(ls_where) then
ls_where =" lb_dm like '"+ ls_lb +"%'"
else
ls_where =ls_where + "and " + "lb_dm like'" + ls_lb + "'"
end if
end if

//入库日期

ldt_rkrq1 = datetime(sle_rkrq1.text)
ldt_rkrq2 = datetime(sle_rkrq2.text)
if isnull(ldt_rkrq1) then
ldt_rkrq1 =datetime(1900-01-01)
end if
if isnull(ldt_rkrq2) then
ldt_rkrq2 = datetime(1900-01-01)
end if
if ldt_rkrq1 <> datetime(1900-01-01) then
ls_where = ls_where + "rkrq >= '"+string(datetime(date(ldt_rkrq1),00:00:00))+"' and "
end if
if ldt_rkrq2 <> datetime(1900-01-01) then
ls_where = ls_where + " rkrq <= '" + string(datetime(date(ldt_rkrq2),23:59:59)) + "' and "
end if

//执行查询

if ls_where = '' or isnull(ls_where) then
w_seek.dw_1.settransobject(sqlca)
w_seek.dw_1.retrieve()
else
//ls_where = left(ls_where,len(ls_where) - 2)
w_seek.dw_1.settransobject(sqlca)
ls_sqlold = w_seek.dw_1.getsqlselect()
ls_sqlnew = ls_sqlold + ' and ' + ls_where
w_seek.dw_1.setsqlselect(ls_sqlnew)
w_seek.dw_1.retrieve()
w_seek.dw_1.setsqlselect(ls_sqlold)
end if
if w_seek.dw_1.rowcount() > 0 then
messagebox("查询结果!","总共查询到"+string(w_seek.dw_1.rowcount())+"条记录符合查询内容!",information!,ok!)
end if

为什么查询出来的结果总为空,前面2个条件一起的时候是没有问题的,所有我猜想是第3个条件进行数据转换的时候出问题了.谁能告诉我哪里错了啊.

搜索更多相关主题的帖子: string date 类型 数据 
2006-08-10 11:26
快速回复:[求助]关于查询中date与string类型数据转换中的问题!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018402 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved