Thread: n00b at reading data from databases need help

  1. #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

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268

  3. #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.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    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.)

  5. #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.

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    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.)

  7. #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?

  8. #8
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    #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."

  9. #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

  10. #10
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    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.

  11. #11
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    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++'?
    Last edited by Cactus_Hugger; 07-16-2009 at 06:04 PM.
    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)

  12. #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 )

  13. #13
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    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
    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.)

  14. #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.

Popular pages Recent additions subscribe to a feed

Similar Threads

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

Tags for this Thread