Recordset not Updated as per query and not giving any error

20 pts.
Tags:
Database programming
Debugging
VB 6
Visual Basic 6
Visual Basic debugging
Dear Sir, thanks for your reply for my earlier query, What I am trying to do is i am editing RM item rate in RM master file.. my code doing it correctly, secondly i am updating bill_detail file for rate where that RM code is used in bill this also my code doing correctly, but third one where i am updating bill file for total_amt field (i.e. in bill_details, RM1, RM2, RM3 items stored and total of their rate*qty is stored in bill ) but here by codedoedn't work. My code updating only first record of bill file. Now please look at my below code :- If Rs.State = adStateOpen Then Rs.Close Rs.Open "select * from product_master where sno=" & Val(LblSr.Caption), Cn, adOpenDynamic, adLockOptimistic Rs("prod_type") = CmbType.Text Rs("prod_sub_type") = TxtName.Text Rs("rate") = Val(TxtRate.Text) Rs("is_active") = Val(ChkActive.Value) Rs.Update Rs.Close If Rs1.State = adStateOpen Then Rs1.Close Rs1.Open "select * from bill_details where prod_sno=" & Val(LblSr.Caption), Cn, adOpenDynamic, adLockOptimistic If Rs1.RecordCount > 0 Then Rs1.MoveFirst Dim OldRt As Integer Dim bILL As Integer Dim newrt As Integer bILL = Rs1("Bill_sno") Dim i As Integer For i = 1 To Rs1.RecordCount OldRt = Rs1("amt") Rs1("rate") = Val(TxtRate.Text) Rs1("amt") = Rs1("rate") * Rs1("qty") / 100 newrt = Rs1("amt") Rs1.Update up to here code is updating all records as per sql select command above, but blow line are only updating first record of bill table If Rs2.State = adStateOpen Then Rs2.Close Rs2.Open "Select * from bill where invoice_no =" & Rs1("Bill_sno"), Cn, adOpenDynamic, adLockOptimistic If Rs2.RecordCount > 0 Then Rs2.MoveFirst Dim j As Integer For j = 1 To Rs2.RecordCount Rs2("total_amt") = Rs2("total_amt") - OldRt + newrt Rs2.Update Rs2.MoveNext Next Rs1.MoveNext End If Next End If Rs1.Close Please help.. Thanks in Advance Regards,

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    Are you sure the query is returning more than one row ? Have you tried displaying Rs2.RecordCount in a message box ? (press the "add to discussion" button to answer)
    68,710 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following