Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB 6 Data grid control

Posted on 2006-07-18
2
Medium Priority
?
298 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Introduction to Processes

730 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