每个数据放在一个字段里,每一条记录有一个标识; 如: dim sqlstring = "select * from tablename where id = '" & x & "';" dim con as new adodb.connection dim vrs as new adodb.recordset con.open "dsn=mydata" vrs.open sqlstring,con if not vrs.eof then do while not vrs.eof z = y - vrs.field("1") z = z - vrs.field(2") ................. movenext loop end if
dim z as double dim Y as double SqlStr = "Select X from TableName" rs.open SqlStr ,连接字符串 if rs.eof and rs.bof then '没有记录 else do while not rs.eof z=y-rs.field("X") debug.pring z rs.movenext loop end if
如:
dim sqlstring = "select * from tablename where id = '" & x & "';"
dim con as new adodb.connection
dim vrs as new adodb.recordset
con.open "dsn=mydata"
vrs.open sqlstring,con
if not vrs.eof then
do while not vrs.eof
z = y - vrs.field("1")
z = z - vrs.field(2")
.................
movenext
loop
end if
dim Y as double
SqlStr = "Select X from TableName"
rs.open SqlStr ,连接字符串
if rs.eof and rs.bof then
'没有记录
else
do while not rs.eof
z=y-rs.field("X")
debug.pring z
rs.movenext
loop
end if
select @y - x as z from tablename
2、arr1(iR,iC)=rs.getrows(好象是这样)把recordset里的记录放到数组arr1里,再计算。