c++ builder 2007, query count record from database
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: c++ builder 2007, query count record from database

  1. #1
    Join Date
    Mar 2011
    Location
    Greece
    Posts
    26

    c++ builder 2007, query count record from database

    Goodmorning

    I have a simple application on C++Builder2007 and access 2007. I want to make a query so when a user hits a button to count the records on a specifiec date. I wrote the above but its not right. I want little help.
    The fields are DATE->Date/Time Type... When i hit the button it says invalid integer.. I try to used the ADODATASET component but i dont have problem with that. Can i use something else;;;Like ADOQUERY. Wich is faster?

    ADODataSet1->Active=false;
    AnsiString query;
    int MaxRecords=0;
    query="SELECT Count (DATE) FROM DEYAS WHERE DATE= '" + Edit14->Text + "'";
    ADODataSet1->CommandText="SELECT COUNT (DATE) FROM BILLS WHERE DATE= '" + Edit14->Text + "'" ;

    ADODataSet1->Active=true;
    Edit17->Text=IntToStr(MaxRecords);
    Last edited by Leite333; October 18th, 2012 at 01:07 AM.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,466

    Re: c++ builder 2007, query count record from database

    What "invalid integer" do you men? It is not clear from your pseudo-code snippets.
    Did you try to debug your code to see what exactly, when and how happens?
    Victor Nijegorodov

  3. #3
    Join Date
    Mar 2011
    Location
    Greece
    Posts
    26

    Re: c++ builder 2007, query count record from database

    Hi. Sorry i thought i was clear. On Edit14->Text there is date with function DateToStr(Date());. I have these fields on database table.

    A/A ->Automatic
    Ammount->Float
    Date->Date/Time with default value =Date()

    So i want the user to hit the button and compare in the database with today date that have in edit14 and return the records.. For example 10 or 20. I dont know how to syntax right the query. How i syntax it first and then how i count it and return it on a new edit.
    When it returns it says invalid integer. How i can see debugging sorry i am new in whole this

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,466

    Re: c++ builder 2007, query count record from database

    Quote Originally Posted by Leite333 View Post
    I dont know how to syntax right the query.
    Then you must first learn the SQL documentation!

    Quote Originally Posted by Leite333 View Post
    ...
    When it returns it says invalid integer. How i can see debugging sorry i am new in whole this
    Then the second thing you must learn is the debugging in C++Builder2007. For example, read this doc: http://www.cs.armstrong.edu/liang/cp...veTeaching.pdf
    Victor Nijegorodov

  5. #5
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,022

    Re: c++ builder 2007, query count record from database

    Every time I to work with explicit SQL queries, first thing I do is checking the SQL syntax in some database client app. Only when I know that it's fully correct, I implement it in my code.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center