Results 1 to 4 of 4

Thread: Updating database table.

  1. #1

    Thread Starter
    Member Ahmed Shahni's Avatar
    Join Date
    Feb 2011
    Posts
    45

    Lightbulb 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.

  2. #2
    PowerPoster make me rain's Avatar
    Join Date
    Sep 2008
    Location
    india/Hubli
    Posts
    2,208

    Re: Updating database table.

    Hello ahmed
    The averted nuclear war
    My notes:

    PrOtect your PC. MSDN Functions .OOP LINUX forum
    .LINQ LINQ videous
    If some one helps you please rate them with out fail , forum doesn't expects any thing other than this

  3. #3
    PowerPoster make me rain's Avatar
    Join Date
    Sep 2008
    Location
    india/Hubli
    Posts
    2,208

    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
    The averted nuclear war
    My notes:

    PrOtect your PC. MSDN Functions .OOP LINUX forum
    .LINQ LINQ videous
    If some one helps you please rate them with out fail , forum doesn't expects any thing other than this

  4. #4

    Thread Starter
    Member Ahmed Shahni's Avatar
    Join Date
    Feb 2011
    Posts
    45

    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
  •  



Click Here to Expand Forum to Full Width