大家帮我看看吧,错在哪儿?

guiyings 2003-09-06 10:31:27
我在数据窗口中放了一个ddlb_1,用它来检索,写成如下代码老报错如下:
string techid , ls_techname
ls_techname = trim(string(ddlb_4.text))
if ls_techname = '' then
messagebox("提示","请输入内容!")
return
end if

select TechID into :techid from Techname where mytechname =:ls_techname;
messagebox("",techid)
dw_3.setsqlselect("select model,sect,state,parameter,time,modifytime,createtime,techid from techdata where TechID = techid")
dw_3.settransobject(sqlca)
dw_3.retrieve()

可是我要是把代码改为如下:
string techid , ls_techname
ls_techname = trim(string(ddlb_4.text))
if ls_techname = '' then
messagebox("提示","请输入内容!")
return
end if

select TechID into :techid from Techname where mytechname =:ls_techname;
messagebox("",techid)
dw_3.setsqlselect("select model,sect,state,parameter,time,modifytime,createtime,techid from techdata where TechID ='21151EE58B1043D2BA8D15F36542D31F'")
dw_3.settransobject(sqlca)
dw_3.retrieve()
一点错误也没有,可以运行.请问,我上面的错误出在哪儿,如何改对呀?
...全文
47 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
athere_08 2003-09-06
  • 打赏
  • 举报
回复
记住用sqlca,sqlcode来判断执行的结果总是一个好的办法。
或者看关键函数的返回值
蹭一点分,呵呵````
liujiaqiang 2003-09-06
  • 打赏
  • 举报
回复
哎,兰兰,你怎么又搞错了呢?
你这样吧:

string techid , ls_techname

ls_techname = trim(string(ddlb_4.text))
if ls_techname = '' then
messagebox("提示","请输入内容!")
return
end if

select TechID into :techid from Techname where mytechname =:ls_techname;
messagebox("",techid)
if isnull(techid) or trim(techid) = '' then
return
en if

dw_3.setsqlselect("select model,sect,state,parameter,time,modifytime,createtime,techid from techdata where TechID = techid") //你就错在这个SQL语句上

dw_3.setsqlselect("select model,sect,state,parameter,time,modifytime,createtime,techid from techdata where TechID ='"+ techid + "'") //这样就可以了,techid是变量,不是字段,下次请记住这些小错误!!!

dw_3.settransobject(sqlca)
dw_3.retrieve()

多联系.......
runsoft 2003-09-06
  • 打赏
  • 举报
回复
来晚了。SQL表达式有问题。
double22822 2003-09-06
  • 打赏
  • 举报
回复
1.大家说得对
2.第一个判断最好加一个or isnull()
happy_0325 2003-09-06
  • 打赏
  • 举报
回复
dw_3.setsqlselect("select model,sect,state,parameter,time,modifytime,createtime,techid from techdata where TechID = techid")
改为

dw_3.setsqlselect("select model,sect,state,parameter,time,modifytime,createtime,techid from techdata where TechID = '"+techid+"'")
xingxing 2003-09-06
  • 打赏
  • 举报
回复
你那个仅仅上一个串,不是一个字段
冷箫轻笛 2003-09-06
  • 打赏
  • 举报
回复
楼上的正解!不过
为什么不用数据窗口的参数
而在这个地方更改检索条件那?
csdsjkk 2003-09-06
  • 打赏
  • 举报
回复
dw_3.setsqlselect("select model,sect,state,parameter,time,modifytime,createtime,techid from techdata where TechID = techid")
这样写:
dw_3.setsqlselect("select model,sect,state,parameter,time,modifytime,createtime,techid from techdata where TechID ='"+ techid + "'")
guiyings 2003-09-06
  • 打赏
  • 举报
回复
说错了,是放了ddlb_4.上面的代码我写在ddlb_4的selectionchanged事件中的.谁能告诉我,错在哪儿?
TIGERWONG 2003-09-06
  • 打赏
  • 举报
回复
兰兰!我来晚一步!!
下次又问题我在解答!!

1,108

社区成员

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

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