Click here to Skip to main content
16,012,168 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Sir,
I'm maintaining a Table in SQLServer with following details.

-----------------------CASH BOOK (LEDGER)----------------------
DATE.......DESCRIPTION......DEBIT..........CREDIT.........BALANCE
1/1/2011..Cash Balance............................................5000
1/1/2011..Sales................3000................................8000
1/1/2011..Shop Rent.............................2500............5500
2/1/2011..Sales................5000..............................10500
2/1/2011..Purchase..............................5500.............5000
3/1/2011..Sales................2000................................7000

Suppose if I use SQL Update command to do so, it could update only particular field/column but I want BALANCE column to be updated same as RUNNING TOTAL method...
In my application I'm using Datagridview Windows Form Visual Basic 2010 to insert records (DATE,DESCRIPTION,DEBIT,CREDIT) but the balance column has to updated.

Thanking you...

MIQUASH.
Posted
Comments
Raj.rcr 14-Mar-11 2:09am    
Not clear..!

1 solution

Hi, as per my knowledge, don't take Balance Column in database, instead u have to calculate Balance when u r binding to DataGridView. i have sample code in php u can use same thing in vb.net

PHP
if($row['credit']!=0){
        $balance = $balance + $row['credit'];
    }
    else if($row['debit']!=0){
        $balance = $balance - $row['debit'];
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900