-
October 18th, 2012, 12:52 AM
#1
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.
-
October 18th, 2012, 01:04 AM
#2
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
-
October 18th, 2012, 01:13 AM
#3
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
-
October 18th, 2012, 02:14 AM
#4
Re: c++ builder 2007, query count record from database
Originally Posted by Leite333
I dont know how to syntax right the query.
Then you must first learn the SQL documentation!
Originally Posted by Leite333
...
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
-
October 20th, 2012, 02:02 AM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|