注册 登录
编程论坛 PowerBuilder

pb中sql的查询错误。。

55Pb 发布于 2006-12-04 22:48, 845 次点击

初学pb,刚写了个查询程序
可是运行结果老是 “ 没有查找到相关记录!”
不知道为什么,达人 指点一下
string cno
string cname
string a
string xianxing
int score

a=sle_1.text
if ddlb_1.text="课程号" then
declare c cursor for
select course.课程号,course.课程名,course.先行课,course.学分
from course
where 课程号=:a;
open c;
do while true
fetch c into:cno,:cname,:xianxing,:score;
if sqlca.sqlcode=100 then
messagebox("注意!","没有查找到相关记录!")
exit
end if
loop
close c;
dw_1.settransobject(sqlca)

dw_1.retrieve()

end if

2 回复
#2
55Pb2006-12-04 22:52
斑竹那。。
#3
werley2006-12-05 19:04

open c;
fetch c into:cno,:cname,:xianxing,:score;//把fetch加在这里第一次取
do while sqlca.sqlcode = 0 //条件
if sqlca.sqlcode=100 then
messagebox("注意!","没有查找到相关记录!")
exit
end if
fetch c into:cno,:cname,:xianxing,:score;;//fetch值控制LOOP
loop
close c;

1