C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 07-16-2009, 09:48 AM   #1
Registered User
 
Join Date: Jul 2009
Posts: 8
Question n00b at reading data from databases need help

Hi, I'm working on a GUI (Visual C++ 2005) that one of the thinks it is supposed to do is take some data from a MySQL database and an excell file do some calculations and show the results.
What I want to know is the commands I need to use to take a data from a specific cell in the database and/or the excell file and for example add it to another non-database variable. For example if the database looks like this

Animal |Age | Collor |
---------------------------------
Dog |5 | Brown |
Cat |3 | White |
Dog |10 |Black |

What commands are needed to lets say have the Age of the Black Dog calculated in human years (5*7)
If there is a site I could look for more info about retrieving Data from databases, I think that will do also.
Thanks
AntV is offline   Reply With Quote
Old 07-16-2009, 09:59 AM   #2
Registered User
 
Join Date: Sep 2004
Location: California
Posts: 2,845
This looks like a good place to start.
bithub is offline   Reply With Quote
Old 07-16-2009, 12:00 PM   #3
Registered User
 
Join Date: Jul 2009
Posts: 8
Smile

Thanks, I guess, but thats a lot of info. I have started reading all that, but if you or somebody else had a more easy solution, please tell me. I must finish this asap and time for encyclopedic reading is not a luxury I have

p.s. I forgot to say that I already have connected the database to the GUI as a data source

Last edited by AntV; 07-16-2009 at 12:10 PM.
AntV is offline   Reply With Quote
Old 07-16-2009, 12:31 PM   #4
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
Quote:
Originally Posted by AntV View Post
Thanks, I guess, but thats a lot of info. I have started reading all that, but if you or somebody else had a more easy solution, please tell me. I must finish this asap and time for encyclopedic reading is not a luxury I have

p.s. I forgot to say that I already have connected the database to the GUI as a data source
That's why there's a table of contents so you can read the parts you need to know.

Also, if you think a 16-page tutorial is "encyclopedic" then you might be in the wrong line of work. (And so far as I can tell the tutorial answers your question by the time you get to page 3.)
tabstop is offline   Reply With Quote
Old 07-16-2009, 12:58 PM   #5
Registered User
 
Join Date: Jul 2009
Posts: 8
Yeah, sorry about that... I started from the top page. Actually the tutorials are great. Now I have a new problem. I try to "play around" with those tutorials, but I am having a problem with some "#include" and "using namespace" command. (for example #include "cmdline.h" and #include "printdata.h" )I get a lot of Cannot open or include file: No such file or directory. I do get those messages a lot...
Btw thanks for all those quick responses

Last edited by AntV; 07-16-2009 at 01:11 PM.
AntV is offline   Reply With Quote
Old 07-16-2009, 01:36 PM   #6
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
So far as I can tell, cmdline.h and printdata.h are part of the mysql++ package. Do you have the entire package? (In fact, those examples there I think are part of the mysql++ package too -- the header files might be in that examples directory.)
tabstop is offline   Reply With Quote
Old 07-16-2009, 02:49 PM   #7
Registered User
 
Join Date: Jul 2009
Posts: 8
So should I just copy all those files in the include folder of Visual Studio or somewhere else?
Isn't that what the install of SQL++ should do?
AntV is offline   Reply With Quote
Old 07-16-2009, 03:25 PM   #8
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
#include "this file" (as opposed to #include <this file>) generally means "this file is in the directory with the code in it, as opposed to the default include library for everything."
tabstop is offline   Reply With Quote
Old 07-16-2009, 05:30 PM   #9
Registered User
 
Join Date: Jul 2009
Posts: 8
I still haven't found how to make use of MySQL++ and theworst is I don't know what I'm doing wrong
AntV is offline   Reply With Quote
Old 07-16-2009, 05:43 PM   #10
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
Quote:
Originally Posted by AntV View Post
I still haven't found how to make use of MySQL++ and theworst is I don't know what I'm doing wrong
It's a bit tricky, 'cause I don't have the package installed -- but have you read the readme for windows? Do you have that examples folder with those sample projects in it? Open those and run with them.
tabstop is offline   Reply With Quote
Old 07-16-2009, 06:02 PM   #11
int x = *((int *) NULL);
 
Cactus_Hugger's Avatar
 
Join Date: Jul 2003
Location: Banks of the River Styx
Posts: 891
Quote:
Originally Posted by AntV View Post
Hi, I'm working on a GUI (Visual C++ 2005) that one of the thinks it is supposed to do is take some data from a MySQL database and an excell file do some calculations and show the results.
What I want to know is the commands I need to use to take a data from a specific cell in the database and/or the excell file and for example add it to another non-database variable. For example if the database looks like this

Animal |Age | Collor |
---------------------------------
Dog |5 | Brown |
Cat |3 | White |
Dog |10 |Black |
"Collor". I'll leave your DB design at that.
Quote:
Originally Posted by AntV View Post
What commands are needed to lets say have the Age of the Black Dog calculated in human years (5*7)
You mean dog years.
Quote:
Originally Posted by AntV View Post
If there is a site I could look for more info about retrieving Data from databases, I think that will do also.
Why does this have to be a program? You say you don't have time to read, so go quick n' dirty. Why not:
Code:
SELECT
    Animal,
    Age,
    'Dog Years' = Age * 7,
    Colour
FROM
    Dog
?

You can build SQL queries directly into an Excel spreadsheet as well, and have it requery when you need it.

You could use the mysql command line utility, which can store the results into a csv file, which you could then do simple I/O on and generate your output.

Finally, are you sure you're working in C++, and not 'managed C++'?
__________________
long time; /* know C? */
Unprecedented performance: Nothing ever ran this slow before.
Any sufficiently advanced bug is indistinguishable from a feature.
Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
The best way to accelerate an IBM is at 9.8 m/s/s.
recursion (re - cur' - zhun) n. 1. (see recursion)

Last edited by Cactus_Hugger; 07-16-2009 at 06:04 PM.
Cactus_Hugger is offline   Reply With Quote
Old 07-16-2009, 06:06 PM   #12
Registered User
 
Join Date: Jul 2009
Posts: 8
That's the whole problem... the projects are just headers that can't be executed by their own and if I just copy the code from them into a new project, it gives me an error of something missing (tried adding the .h files in the same directory, but no luck). Also the install file says to view the corresponding Read Me file, but in there there are no install-relative info. I tried googling around but the only thing I got is how to make some changes so that it runs in Form and MFC applications and although I did those as well it just doesn't work. Any other ideas? (btw you were right, if I do get this to work, I'll be almost finished )
AntV is offline   Reply With Quote
Old 07-16-2009, 06:13 PM   #13
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
Quote:
Originally Posted by AntV View Post
That's the whole problem... the projects are just headers that can't be executed by their own
Are you sure. Are you really really sure. Because the samples that I'm looking at, that they claim are included, are most definitely not "just headers that can't be executed". For example, simple2.cpp (supposed to be in the examples folder) is most definitely a complete, runnable program.

Also, did you read the bit that says
Quote:
MySQL++ comes with the exrun shell script for Unixy systems, and the exrun.bat batch file for Windows. You pass the example program and its arguments to the exrun helper, which sets up the library search path so that it will use the as-yet uninstalled version of the MySQL++ library in preference to any other on your system:

./exrun resetdb [-s server_addr] [-u user] [-p password]

That's the typical form for a Unixy system. You leave off the ./ bit on Windows. You can leave it off on a Unixy system, too, if you have . in your PATH. (Not a recommendation, just an observation.)
(That may or may not be necessary of course.)
tabstop is offline   Reply With Quote
Old 07-17-2009, 08:33 AM   #14
Registered User
 
Join Date: Jul 2009
Posts: 8
Problem is that when I try to execute the Mysql++.sln I get about the following errors saying the same thing: Cannot open or include file: 'Mysql_version.h': No such file or directory, Cannot open file: 'Mysqlpp_excommon.h': No such file or directory. (I also tried reinstalling MySQL server and include all files, but no change)
Has anyone used MySQL++ and knows how to make it work on a windows platform?

Update: I found a guide for installing it here done everything (exept for part 10, it says "Cannot find the path specified") and now instead of the previous "not found" errors, I get new ones for "libmysql.lib" and "libmysqlpp_d.lib"

Last edited by AntV; 07-17-2009 at 09:50 AM.
AntV is offline   Reply With Quote
Reply

Tags
c++, data, database, retrieve, visual

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading large complicated data files dodzy C Programming 16 05-17-2006 04:57 PM
accessing my com port, writing and reading data shoobsie C Programming 7 09-16-2005 03:29 PM
HUGE fps jump DavidP Game Programming 23 07-01-2004 10:36 AM
reading data format into program lambs4 C Programming 1 10-23-2003 02:27 PM
C diamonds and perls :°) Carlos A Brief History of Cprogramming.com 7 05-16-2003 10:19 PM


All times are GMT -6. The time now is 02:05 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22