请教老师:
有两个表:表A(10000条记录)和表B(2000条记录),主键均为 _Identify
表B中有一个字段“编号”,类型为整形,存放从表A复制记录时的表A的_Identify的值
当前主表是表B,在表B的主窗口中放置一个按钮(btn提取数据),点击按钮时,将表A的所有不在表B中的记录复制到表B中,
代码该怎么写?我下面的代码提示[查询超时已过期,未将对象引用到对象的实例],用消息框看ids的值是空的
请老师看看有什么问题?
dim tb as table = e.form.controls("Table1").table
dim flt as string = ""
if tb.rows.count > 0 then
dim ids as string
for each r as row in tb.rows
ids = ids & r("编号") & ","
next
flt = "[_Identify] not in (" & ids.trim(",") & ")"
endif
dim sCols() as string = {"_Identify","字段1","字段2","字段3"}
dim dCols() as string = {"编号","字段1","字段2","字段3"}
dim cmd as new sqlcommand
cmd.c
cmd.commandtext = "sel ect * from 表A where " & flt
dim dt as datatable = cmd.executereader()
for each dr as datarow in dt.datarows
dim nr as datarow = tb.datatable.addnew()
for i as integer = 0 to sCols.length-1
nr(dCols(i)) = dr(sCols(i))
next
next