did = "Provider=MSDASQL.1;;Persist Security Info=False;User ID=mes;Data Source=comm;password=mesuser"
Set conn = New ADODB.Connection
conn.ConnectionString = connStr
conn.Open did
sql = "SELECt id, exam_no, xxdm, xxmc, ksbm, ksmc, cvalue, doctor, age,
gender, name, depord, proord, flag, bs FROM oa_tj_detail"
rs.Open sql, conn, adOpenStatic, adLockOptimistic, adCmdText
If rs.RecordCount > 0 Then
rs.MoveFirst
Else
Exit Sub
End If
With rsnew
rsnew.Fields.Append "id", adVariant
rsnew.Fields.Append "exam_no", adVariant
rsnew.Fields.Append "xxdm", adVariant
rsnew.Fields.Append "xxmc", adVariant
rsnew.CursorType = adOpenStatic
rsnew.LockType = adLockOptimistic
rsnew.Open
End With
For i = 0 To rs.RecordCount - 1
rsnew.AddNew
rsnew.Fields("id").Value = rs.Fields("id").Value
rsnew.Fields("exam_no").Value = rs.Fields("exam_no").Value
rsnew.Fields("xxdm").Value = rs.Fields("xxdm").Value
rsnew.Fields("xxmc").Value = rs.Fields("xxmc").Value
If i <= rs.RecordCount - 1 Then
rs.MoveNext
End If
Next i
If rs.EOF = True Then
Else
rsnew.MoveFirst
End If
Set DataGrid1.DataSource = rsnew
DataGrid1.Refresh
flag = 0
End Sub
现在运行到 rsnew.Fields.Append "id", adVariant就报错实时错误‘424’ 要求对象,求解
新建了个vb程序,运行到 rsnew.Fields.Append "id", adVariant就报错实时错误‘424’ 要求对象,求解
答案:2 悬赏:80 手机版
解决时间 2021-03-15 09:42
- 提问者网友:缘字诀
- 2021-03-14 23:14
最佳答案
- 五星知识达人网友:酒安江南
- 2021-03-14 23:23
没有在你的程序中看到任何
rsnew 对象的定义及初始化代码
当然会出错
执行rsnew.Fields.Append "id", adVariant时,该 对象还是 nothing
rsnew 对象的定义及初始化代码
当然会出错
执行rsnew.Fields.Append "id", adVariant时,该 对象还是 nothing
全部回答
- 1楼网友:不想翻身的咸鱼
- 2021-03-15 00:04
你好!
rsnew看上去是一个RecordSet对象,可是没看到你有变量声明,就直接使用了,不出错才怪呢
仅代表个人观点,不喜勿喷,谢谢。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯