以下是引用吹水佬在2014-7-5 10:26:55的发言:
** 用数据关联举个例子
CREATE CURSOR stu (学号 C(5), 姓名 C(10))
INSERT INTO stu VALUES ("93061", "王燕")
INSERT INTO stu VALUES ("93062", "李丽")
INSERT INTO stu VALUES ("93063", "詹贵")
INSERT INTO stu VALUES ("93064", "潘泰")
INSERT INTO stu VALUES ("93065", "戚莎")
INSERT INTO stu VALUES ("92061", "张平")
INSERT INTO stu VALUES ("92062", "赵东")
CREATE CURSOR kc (课程号 C(4), 课程名 C(10))
INSERT INTO kc VALUES ("C801", "数据结构")
INSERT INTO kc VALUES ("C802", "多媒体")
INSERT INTO kc VALUES ("C803", "数据库")
INSERT INTO kc VALUES ("C804", "C++语言")
INSERT INTO kc VALUES ("C805", "WEB设计")
INSERT INTO kc VALUES ("C806", "操作系统")
INSERT INTO kc VALUES ("C807", "接口技术")
INSERT INTO kc VALUES ("C808", "程序设计")
CREATE CURSOR xk (学号 C(5), 课程号 C(4), 成绩 I)
INSERT INTO xk VALUES ("93061", "C808", 61)
INSERT INTO xk VALUES ("93061", "C803", 78)
INSERT INTO xk VALUES ("93062", "C803", 90)
INSERT INTO xk VALUES ("93062", "C804", 48)
INSERT INTO xk VALUES ("93063", "C804", 89)
INSERT INTO xk VALUES ("93063", "C803", 65)
INSERT INTO xk VALUES ("93064", "C806", 82)
INSERT INTO xk VALUES ("92061", "C804", 91)
INSERT INTO xk VALUES ("93065", "C802", 70)
INSERT INTO xk VALUES ("92062", "C805", 76)
SELECT stu
INDEX on 学号 TAG 学号
SELECT kc
INDEX on 课程号 TAG 课程号
SELECT xk
SET RELATION TO 学号 INTO "stu", 课程号 INTO "kc"
m课程名 = INPUTBOX("输入查询课程名")
IF !EMPTY(m课程名)
**BROWSE FIELDS xk.学号, stu.姓名, xk.成绩 FOR RTRIM(kc.课程名) == "数据库"
SET FILTER TO RTRIM(kc.课程名) == ALLTRIM(m课程名)
GO TOP
BROWSE FIELDS xk.学号, stu.姓名, xk.成绩
SET FILTER TO
GO TOP
ENDIF
SET RELATION TO
** 用数据关联举个例子
CREATE CURSOR stu (学号 C(5), 姓名 C(10))
INSERT INTO stu VALUES ("93061", "王燕")
INSERT INTO stu VALUES ("93062", "李丽")
INSERT INTO stu VALUES ("93063", "詹贵")
INSERT INTO stu VALUES ("93064", "潘泰")
INSERT INTO stu VALUES ("93065", "戚莎")
INSERT INTO stu VALUES ("92061", "张平")
INSERT INTO stu VALUES ("92062", "赵东")
CREATE CURSOR kc (课程号 C(4), 课程名 C(10))
INSERT INTO kc VALUES ("C801", "数据结构")
INSERT INTO kc VALUES ("C802", "多媒体")
INSERT INTO kc VALUES ("C803", "数据库")
INSERT INTO kc VALUES ("C804", "C++语言")
INSERT INTO kc VALUES ("C805", "WEB设计")
INSERT INTO kc VALUES ("C806", "操作系统")
INSERT INTO kc VALUES ("C807", "接口技术")
INSERT INTO kc VALUES ("C808", "程序设计")
CREATE CURSOR xk (学号 C(5), 课程号 C(4), 成绩 I)
INSERT INTO xk VALUES ("93061", "C808", 61)
INSERT INTO xk VALUES ("93061", "C803", 78)
INSERT INTO xk VALUES ("93062", "C803", 90)
INSERT INTO xk VALUES ("93062", "C804", 48)
INSERT INTO xk VALUES ("93063", "C804", 89)
INSERT INTO xk VALUES ("93063", "C803", 65)
INSERT INTO xk VALUES ("93064", "C806", 82)
INSERT INTO xk VALUES ("92061", "C804", 91)
INSERT INTO xk VALUES ("93065", "C802", 70)
INSERT INTO xk VALUES ("92062", "C805", 76)
SELECT stu
INDEX on 学号 TAG 学号
SELECT kc
INDEX on 课程号 TAG 课程号
SELECT xk
SET RELATION TO 学号 INTO "stu", 课程号 INTO "kc"
m课程名 = INPUTBOX("输入查询课程名")
IF !EMPTY(m课程名)
**BROWSE FIELDS xk.学号, stu.姓名, xk.成绩 FOR RTRIM(kc.课程名) == "数据库"
SET FILTER TO RTRIM(kc.课程名) == ALLTRIM(m课程名)
GO TOP
BROWSE FIELDS xk.学号, stu.姓名, xk.成绩
SET FILTER TO
GO TOP
ENDIF
SET RELATION TO
找不到变量m课程名 怎么回事?