GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 22-Sep-2005, 02:32
bryan523 bryan523 is offline
Junior Member
 
Join Date: Aug 2005
Posts: 32
bryan523 is on a distinguished road

Hw to choose certain field in mysql input by user in visual C++/MFC and display in CR


Hi all,

I got one problem in displaying data from mysql in crystal report!
the crystal report i used was version 8.0.
As I know crystal report can display the data from database after setting manually!
If I got a program doing in MFC which allow user to select to display
certain period of the data by date, hw the crystal report know the string(date)
choose by user and display it? What setting or sql query we need to do in crystal report?

Thanks!
  #2  
Old 22-Sep-2005, 03:43
kobi_hikri's Avatar
kobi_hikri kobi_hikri is offline
Regular Member
 
Join Date: Apr 2005
Location: Israel
Posts: 431
kobi_hikri has a spectacular aura aboutkobi_hikri has a spectacular aura about

Re: Hw to choose certain field in mysql input by user in visual C++/MFC and display in CR


Quote:
Originally Posted by bryan523
If I got a program doing in MFC which allow user to select to display
certain period of the data by date, hw the crystal report know the string(date)
choose by user and display it? What setting or sql query we need to do in crystal report?

Your question is strictly SQL.
Say you have the table "errors" which contains the field "date_reported",
and you wish to display the records in "errors" with "date_reported" between 10/3/2004 and 12/3/2005.
Now, say the date is stored as the number of days from the year 0 (if the date is stored in another way you will have to do a conversion to simplify your work) then :

"
SELECT *
FROM errors
WHERE date_reported >= min_value
and date_reported <= max_value
"

Now,don't change anything in the way you bind the data to your OCX,
simply set the SQL string and call the method "your_data_control.refresh" (I believe it's called refresh but check this).

Best regards,
Kobi Hikri.
__________________
It's actually a one time thing (it just happens alot).
  #3  
Old 22-Sep-2005, 04:31
bryan523 bryan523 is offline
Junior Member
 
Join Date: Aug 2005
Posts: 32
bryan523 is on a distinguished road

Re: Hw to choose certain field in mysql input by user in visual C++/MFC and display in CR


Quote:
Originally Posted by kobi_hikri
Your question is strictly SQL.
Say you have the table "errors" which contains the field "date_reported",
and you wish to display the records in "errors" with "date_reported" between 10/3/2004 and 12/3/2005.
Now, say the date is stored as the number of days from the year 0 (if the date is stored in another way you will have to do a conversion to simplify your work) then :

"
SELECT *
FROM errors
WHERE date_reported >= min_value
and date_reported <= max_value
"

Now,don't change anything in the way you bind the data to your OCX,
simply set the SQL string and call the method "your_data_control.refresh" (I believe it's called refresh but check this).

Best regards,
Kobi Hikri.

Thanks but i dun knw whr should i put the method "your_data_control.refresh" and what u mean your_data_control?

my program got one list box which user can select from what date to what date to report the data in Crystal Report! i cannot set the min_value and max_value bcos its should set by the user whn the program is running. so hw the Crystal report will know the min_value and max_value choose by user?
  #4  
Old 22-Sep-2005, 04:52
kobi_hikri's Avatar
kobi_hikri kobi_hikri is offline
Regular Member
 
Join Date: Apr 2005
Location: Israel
Posts: 431
kobi_hikri has a spectacular aura aboutkobi_hikri has a spectacular aura about

Re: Hw to choose certain field in mysql input by user in visual C++/MFC and display in CR


Quote:
Originally Posted by bryan523
Thanks but i dun knw whr should i put the method "your_data_control.refresh" and what u mean your_data_control?

my program got one list box which user can select from what date to what date to report the data in Crystal Report! i cannot set the min_value and max_value bcos its should set by the user whn the program is running. so hw the Crystal report will know the min_value and max_value choose by user?

I understood what you did.
After the user selects his "from" date and "untill" date, translate the dates to the format you store in the table.
Then, set a variable to the min_value and another variable to the max_value.
You can call them whatever names you wish, I used "min_value" and "max_value" unly to demontrate my point.
Then build the SQL statement (You can use strcat to concatenate the parts of the SQL statement) and set your data control SQL string to the string you built.This is what I meant by "your_data_control" (Simply the name you gave the control you placed on your GUI).
Then, call the refresh method to execute the SQL statement. If the control is binded correctly to a data display control (try using the flex data grid, it is very convenient to modify) then the data will be presented (perhaps you need to refresh the data display control too).

Kobi Hikri.
__________________
It's actually a one time thing (it just happens alot).
  #5  
Old 22-Sep-2005, 22:16
bryan523 bryan523 is offline
Junior Member
 
Join Date: Aug 2005
Posts: 32
bryan523 is on a distinguished road

Re: Hw to choose certain field in mysql input by user in visual C++/MFC and display in CR


Thanks for ur kindly help!
i knw what u meant already!
  #6  
Old 23-Sep-2005, 03:33
kobi_hikri's Avatar
kobi_hikri kobi_hikri is offline
Regular Member
 
Join Date: Apr 2005
Location: Israel
Posts: 431
kobi_hikri has a spectacular aura aboutkobi_hikri has a spectacular aura about

Re: Hw to choose certain field in mysql input by user in visual C++/MFC and display in CR


Quote:
Originally Posted by bryan523
Thanks for ur kindly help!
i knw what u meant already!

Only tried to help, dude.
No need to get angry.

Be well,
Kobi Hikri.
__________________
It's actually a one time thing (it just happens alot).
  #7  
Old 25-Sep-2005, 19:19
bryan523 bryan523 is offline
Junior Member
 
Join Date: Aug 2005
Posts: 32
bryan523 is on a distinguished road

Re: Hw to choose certain field in mysql input by user in visual C++/MFC and display in CR


i am sincerely thanks for your help, really! Dun misunderstood!
if i let you felt i am angry, i would like to say sorry! Again, thanks!
 
 

Recent GIDBlogVista ?Widgets? on Windows XP by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! Some basal questions about MFC xutingnjupt MS Visual C++ / MFC Forum 1 05-Dec-2004 03:38

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 07:11.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.