|
-
Mar 5th, 2011, 12:44 PM
#1
Thread Starter
Member
Updating database table.
Dear Sir,
Below mention code I used in Visual Basic 6 to update my MS Access Table to get UPDATED Balance Column. Now my problem is the same code I want to use in Visual Basic 2010 to update SQLserver Table. Can u guide me pls.
SQL Code in VB6.
With recordsetBank
.MoveFirst
Balance = .Fields("Balance")
Do While .EOF = False
Balance = Balance + .Fields("Debit") - .Fields("Credit")
.Fields("Balance") = Balance
.MoveNext
Loop
End With
For ur information : I have Dataset, Bindingsource and TableAdaptor in Windows Form so with that how can I update my Balance Column. The Table contained 3 columns i. Debit ii. Credit iii. Balance.
Thanks.
-
Mar 6th, 2011, 12:04 AM
#2
Re: Updating database table.
-
Mar 6th, 2011, 12:49 AM
#3
Re: Updating database table.
why Update ,
instead a simple select query will give the out put what you are in need, and it responds any changes in the data base dynamically.
just create a view and save it that's all it will work as table
say for example your table name is Ledger
Code:
SELECT Ledger.Debit, Ledger.Credit, [Ledger]![Debit]-[Ledger]![Credit] AS BALANCE FROM Ledger;
this view will give your data out put what you are trying for
-
Mar 6th, 2011, 03:01 AM
#4
Thread Starter
Member
Re: Updating database table.
Yes your way also correct but my idea it is in my mind and I used in vb6 that above code also I told u before that Running Total Matter, can u remember. Of course I used the same command in vb to get Running total update. Once I click command button from vb form its gets update.
Pls try with my same code and reply to me.
Thanks.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|