查询问题

wang131425 2004-11-03 09:03:46
string s2,d1,e2,e1,c,s1
s1=trim(sle_1.text)
s2=trim(sle_2.text)
d1=trim(ddlb_1.text)
e1 = trim(em_1.text)
e2 = trim(em_2.text)
if cbx_1.checked = false then
if s1 = '' and s2 = '' and d1 = '' then
messagebox('错误',"查询条件不能为空!")
return
else
if s1="" then s1 = '%'
if d1="" then d1 = '%'
if s2="" then s2 = '%'
dw_1.settransobject(sqlca)
c="select * from 商品信息 where 商品编号 like '"+s1+"' and 商品名称 like '"+s2+"' and 商品类型 like '"+d1+"'"
dw_1.setsqlselect(c)
dw_1.retrieve()
end if
else
if s1="" then s1 = '%'
if d1="" then d1 = '%'
if s2="" then s2 = '%'
dw_1.settransobject(sqlca)
c="select * from 商品信息 where 商品编号 like '"+s1+"' and 商品名称 like '"+s2+"' and 商品类型 like '"+d1+"' and 入库日期 > '"+e1+"' and 入库日期 < '"+e2+"'"
dw_1.setsqlselect(c)
dw_1.retrieve()
end if
integer al
al=dw_1.rowcount()
if al =0 then
messagebox('消息',"无符合条件的数据!")
else
st_9.text=string(al)
end if
dw_1.object.datawindow.readonly = "yes"
以上是我查询中的代码。保存时是没有任何问题的。但运行的时候提示:
select error:coiumn lists do not match
我看了一下,表里面的列是对得上的,我用的是ASA的数据库。大家帮忙看看是哪里的问题。先谢过了。
...全文
200 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wang131425 2004-11-04
  • 打赏
  • 举报
回复
还是出现问题。我已经把代码改成只查询其中一个了:
string s2,d1,e2,e1,c,s1
s1=trim(sle_1.text)
s2=trim(sle_2.text)
d1=trim(ddlb_1.text)
e1 = trim(em_1.text)
e2 = trim(em_2.text)
//if cbx_1.checked = false then
if s1 = '' and s2 = '' and d1 = '' then
messagebox('错误',"查询条件不能为空!")
return
else
if s1="" then s1 = '%'
if d1="" then d1 = '%'
if s2="" then s2 = '%'
dw_1.settransobject(sqlca)
c="select * from 商品信息 where 商品编号 = '"+s1+"'"
//c="select * from 商品信息 where 商品编号 like '"+s1+"' and 商品名称 like '"+s2+"' and 商品类型 like '"+d1+"'"
//dw_1.setsqlselect(c)
dw_1.Modify("DataWindow.Table.Select= '"+c+"'")
dw_1.retrieve()
end if
这是运行时提示的错误:
select error:SQLSTATE = 37000
[sybase][odbc driver][adaptive server antwhere]syntax error or access violation:syntax error near '(end of line )' on line
大家再帮忙看看。谢谢了
hyf_0023 2004-11-04
  • 打赏
  • 举报
回复
同意笨笨,高手,你的入库日期 是什么类型估计不对。
TTLOVEYOU3344 2004-11-04
  • 打赏
  • 举报
回复
dw_1.setsqlselect(c)換成dw_1.Modify("DataWindow.Table.Select=‘“+c+"'")試試如果不行,換
用string presentation_str
presentation_str = "style(type=grid)"

dwsyntax_str = SQLCA.SyntaxFromSQL(c, &
presentation_str, ERRORS)

IF Len(ERRORS) > 0 THEN
MessageBox("Caution", &
"SyntaxFromSQL caused these errors: " + ERRORS)
RETURN

END IF

dw_1.Create( dwsyntax_str, ERRORS)

IF Len(ERRORS) > 0 THEN
MessageBox("Caution", &
"Create cause these errors: " + ERRORS)
RETURN

END IF
dw_1.settransobject(sqlca)
ll_row = dw_1.retrieve()
li_d_s 2004-11-04
  • 打赏
  • 举报
回复
"select * from 商品信息",是不是后来增加过字段或者datawindow一开始没有选择所有的字段,或者是选择字段的顺序和表的字段顺序不一致
nccxl 2004-11-04
  • 打赏
  • 举报
回复
你把你写的查询语句带上条件,粘到数窗里去试试,估计是SQL语句不正确。另外你调试一下,看看运行时那些参数值是不是你预期的。
wang131425 2004-11-04
  • 打赏
  • 举报
回复
用了FILTER后已经解决了。不过还是要谢谢各位
wang131425 2004-11-03
  • 打赏
  • 举报
回复
是的。
biliky 2004-11-03
  • 打赏
  • 举报
回复
ASA的数据库???

1,108

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧