本文介绍了Vb6记录更新错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在vb6中,包含以下值的表单和这里是示例值的截图链接!

In vb6, a form containing following values and here is the screenshot link for the sample values !

我正在使用Ms Access 2007,它包含一个名为studentexamdetail的表,包含

And I am using Ms Access 2007 and it contains a table named "studentexamdetail" contains

    heading(Admno,Semester,Subjectcode,Regular_Arrear,Fee)

而我的怀疑是当我点击上面的保存按钮(见截图),然后入学号码,学期,所有的主题代码,常规日志(我们可以手动编写),费用应保存在studentexamdetail表中,但它只存储第一个值当我使用这种方法!

And my doubt is when i click "Save" button in above form(see screenshot), then admission number,semester,all the subjectcode, regular_arrear(we can write manually) and Fee should saved in the "studentexamdetail" table but it stores 1st value only when i use this method !

    rs2.Open "select * from studentexamdetail", con, 1, 3
    Do Until rs2.EOF
    rs2.AddNew
    rs2!AdmnNo = admno.Caption
    rs2!semester = semester.Caption
    rs2!Subjectcode = rs.Fields("Subjectcode")
    rs2!Regular_Arrear = "Regular"
    rs2!Fee = rs.Fields("Fee")
    rs2.Update
    rs2.MoveNext
    MsgBox "Record Saved!"
    Loop

我应该做什么改变来存储所有的值,而不是第一个值?
我需要的是,如下所示:

What changes should i made to store all the values and not 1st value only?What i need is, I shown below :

    Admno Semester Subjectcode Regular_Arrear Fee
    1471     V       RMSC1        Regular     440
    1471     V       RMSC3        Regular     440
    1471     V       RMSC2        Regular     320

我想我们已经通过将rs2.movenext替换成rs2.movenext来解决问题,解决了这个问题,就像上面那样保存那个表中的数值!

I want to save values in that table as like above only !

推荐答案

rs.movenext,您可以在上面的评论中看到rs记录集的值,我只是放了另一段代码rs2.close

I have solved the problem by replacing the "rs2.movenext" to "rs.movenext" and you can see the rs recordset value in the comment above and i just placed another piece of code "rs2.close"

   Do Until rs.EOF
   rs3.Open "select * from studentexamdetail", con, 1, 3
   rs3.AddNew
   rs3!AdmnNo = admno.Caption
   rs3!semester = semester.Caption
   rs3!Subjectcode = rs.Fields("Subjectcode")
   rs3!Regular_Arrear = "Regular"
   rs3!Fee = rs.Fields("Fee")
   rs3.Update
   rs3.Close
   rs.MoveNext
   Loop
   MsgBox "Record Saved!"

感谢上帝!

这篇关于Vb6记录更新错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 19:34