Jump to content

TABLE RUNNING TOTAL.


Miquash

Recommended Posts

Dear Sir,I'm maintaining a Table in SQLServer with following details.---------------------------------CASH BOOK (LEDGER)----------------------DATE........DESCRIPTION.........DEBIT.............CREDIT.........BALANCE1/1/2011..Cash Balance.....................................................50001/1/2011..Sales...........................3000...............................80001/1/2011..Shop Rent....................................2500...............55002/1/2011...Sales.........................5000..............................105002/1/2011...Purchase.....................................5500..............50003/1/2011...Sales.........................2000...............................7000Suppose if I use SQL "Update" command it could update only particular field/column but I want get BALANCE 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 how can I get Balance column updated.Thanking you...MIQUASH.

Link to comment
Share on other sites

I don't really understand the question but this raw SQL seems to work; INSERT INTO ACCOUNT (TDate, Descrip, Debit, Credit, Balance)VALUES ('3/15/2011', 'Purchase', 1000.00, 0.00, ((SELECT TOP (1) BalanceFROM ACCOUNT ORDER BY TDate DESC )-1000.00) );Obviously this doesn't show the VB or C# string-building.It might not be reliable in a multi-user system unless you lock the table, but I'm not sure about that.Maybe you are simply asking how to access the datagridview cells with a routine? In VB I use;dAmt = System.Convert.ToDouble(DGV001.Rows(i).Cells(j).Value.ToString)DGV001.Rows(i).Cells(j).Value = dAmt

Link to comment
Share on other sites

Sir,Thanks for your reply and it works for single records ok. Now I will tell you how I need.The above table contained daily CASHBOOK entries in Accounts with Date, Description Debit, Credit ok the Balance Column I have to update end of the month so manually it takes longtime my present table looks like :..Date......Desc..................Debit..............Credit............Balance1/1........Cash Balance................................................50001/1........Sales................2000.....................................2/1........Purchase...................................2000.............3/1........Sales................3000.....................................4/1........Rent.........................................1000.............the above transaction continuing upto 31/1/2011 without balance column update ok. Now I want to update all the rows onetime complete month.Balance should Cash Balance + Debit - Credit = BalanceI did in vb0.6 with WHILE LOOP CODE, but I do not know how do in vb.net (Visual Basic 2010 & Database SQLServer)Please help me to solve it..

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...