Solved

VB 6 Data grid control

Posted on 2006-07-18
2
291 Views
Last Modified: 2010-04-17
Sir, I am using data grid in my application, which have three columns.

1.     Job #
2.     Balance Amount
3.     Received Amount

The one and two columns are locked, in other words user can not enter data in column one and two however three is open for user for entering received amount against of balance.

For example we have twenty jobs/rows on grid which payment we have not received yet. However we received payment only against four job then user go on respective job # and enter data in column received amount what ever he received. After updating four jobs in data grid against which he received payment user click save button and on click I want to run a loop to update respective four rows against which we have received amount in database.

Please help how it possible

Rgds.
Mehram
0
Comment
Question by:Mehram
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
assyst earned 500 total points
ID: 17131222
I believe you are asking for the code to update the data from datagrid to database

We can save the data row by row from the datagrid. we have to use a loop for doing this.

You have to create a recordset for this and

Private sub cmdSave_Click

Dim recSave as new ADODB.recordset
irecSave.open "Select * From <table name> where null=null", <connection object>, <lock type>

rec.movefirst
while rec.eof = false
    if val(rec.fields("Received Amount")) <> 0
       recSave.addnew
           recSave.Fields("Job #") = rec.Fields("Job #")
           recSave.Fields("Balance Amount") = rec.Fields("Balance Amount")
           recSave.Fields("Received Amount") = rec.Fields("Received Amount")
       recSave.update
    end if
 rec.movenext
wend
recSave.Close
end sub
0
 

Expert Comment

by:misbah_ra
ID: 17132403
We can save the data row by row from the datagrid. we have to use a loop for doing this.

You have to create a recordset for this and

Private sub cmdSave_Click

Dim recSave as new ADODB.recordset
irecSave.open "Select * From <table name> where null=null", <connection object>, <lock type>

rec.movefirst
while rec.eof = false
    if val(rec.fields("Received Amount")) <> 0
       recSave.addnew
           recSave.Fields("Job #") = rec.Fields("Job #")
           recSave.Fields("Balance Amount") = rec.Fields("Balance Amount")
           recSave.Fields("Received Amount") = rec.Fields("Received Amount")
       recSave.update
    end if
 rec.movenext
wend
recSave.Close
end sub
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C# Error - Add Failed 12 99
youtube blocking politics 4 79
Hide file extensions in Notepad++ tabs 2 49
Java pass by reference 3 18
A short article about problems I had with the new location API and permissions in Marshmallow
In this post we will learn different types of Android Layout and some basics of an Android App.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question