CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Ledger

  1. #1
    Join Date
    Aug 1999
    Location
    Pakistan
    Posts
    366

    Ledger

    I am developing a datebase Program in VB6.0 for which I have placed a Text Box on a certain form.This text box is to contain the sum of all the values in a certain column of DBGrid control.
    I simply cannot comeup with a code to tell the program to go through the column.
    Urgent help is neede as my project is stuck
    Thankx in advace...


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Ledger

    yesterday, Chris Eastwood posted code for iterating over all rows of a dbgrid using the TextArray property of the grid control.
    Use that to calculate the sum of a certain column.


  3. #3
    Join Date
    Apr 1999
    Location
    Netherlands
    Posts
    181

    Re: Ledger

    Or use a SUM SQL query if possible (which is probably faster then looping through the control to get the values)

    Crazy D @ Work :-)

  4. #4
    Join Date
    Aug 1999
    Location
    Pakistan
    Posts
    366

    Re: Ledger

    I have tried using the SUM in SQL:
    Select [Sum(ColumnName)] as [DummyName] from [DatabaseTable]
    It works fine in Data Manager but when I use the following code

    Dim Sql as string
    Sql= Above Statement
    Adodc1.recordsource=sql
    adodc1.refresh



    the following error occurs
    "At least one Parameter is missing"
    I would appreciate if any help is extended
    Thankx in advance


  5. #5
    Guest

    Re: Ledger

    It works Fine. Check parentheses.


  6. #6
    Join Date
    Aug 1999
    Location
    Pakistan
    Posts
    366

    Re: Ledger

    Thanks for the hint.I have already checked paranthses but it still does not work.
    What do u say about the fact that when the Recordsource Property of ADODc is set to cmd Table ,the ADODC control does not accept any SQL Commands ,even through VB Code.If I set it to cmdTExt then it does not allow me to move further unless I put an SQL Query in the text box.
    Which query works: the one in the Property Page or the one in the Code
    Thankx in advance...


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

Featured