|
问题:如何把表Student中的学号,读入到StudentScoreDP中,这样才可以根据学号添加学生成绩档案?中间要求借助datapool!
两个表的结构!
“新增学生”模块所用表及字段如下图所示:
Student
字段名称 类型
学号 varchar
姓名 varchar
性别 varchar
年龄 int
“新增学生成绩档案”所用表及字段如下图所示:
StudentScore
字段名称 类型
学号 varchar
英语 varchar
化学 varchar
物理 varchar
我下边写了一个简单的实现代码!提供给大家参考
dim ACnn as object
dim BCnn as Object
Dim ARst as Object
Dim BRst as Object
dim AstrCnn as string
dim BstrCnn as string
Dim Result As Integer
Dim dp_id as Long
Dim dp_Result as Long
'datapool列名
dim 1 as string
dim 2 as string
。。。。。。。。。
dim x as string
set ACnn = CreateObject("Adodb.Connection")
set BCnn = CreateObject("Adodb.Connection")
set ARst = CreateObject("Adodb.Recordset")
set BRst = CreateObject("Adodb.Recordset")
AstrCnn="联接新增学生数据库字符串"
BstrCnn="联接新增学生成绩档案数据字符串"
ACnn.open AstrCnn
BCnn.open BstrCnn
ARst.open "select * from 新增学生表",ACnn
BRst.Open "select * from 新增学生成绩档案",BCnn
ARst.movefirst
dp_id = SQADatapoolOpen ("dp", FALSE, SQA_DP_SEQUENTIAL, FALSE)
dp_Result = SQADatapoolFetch (dp_id)
While not ARst.eof
Brst.Fields("0") = ARst.Fields("0") '两个表中的学号一致 直接赋予第一个
dp_Result = SQADatapoolValue (dp_id, "列1", 1)
dp_Result = SQADatapoolValue (dp_id, "列2", 2)
Brst.Fields("1") = 1
Brst.Fields("2") = 2
。。。。。。。。。。
Brst.Fields("x") = x
dp_Result = SQADatapoolFetch (dp_id)
loop
ARst.close
Brst.Close
ACnn.close
BCnn.Close
set ARst =nothing
set BRst =nothing
set ACnn = nothing
set BCnn = nohhing |
|