Let me explain myself, and then hopefully you can tell me a better solution.

I have paid web hosting (only $2.50/mo) and in the process of learning PHP, have learned how to work with MySQL databases.

I was wondering if it is possible to create a program in C++ that is able to log into the MySQL database (with a hardcoded query) and displayed the returned data.

I would want the returned data to be separated and stored in local variables on the C++ program.

Once I get this working, I would probably split up the program into Client and Server models, and have only the Server query the database. This database would most likely end up being a local SQL database on the same machine the server is running on.

Where do I start?

:) Thanks for the help!

[edit]
I wasn't clear at the end.

If it IS possible to have C++ query a local SQL database, I would rather do that than bother with hosted databases on a website.

Recommended Answers

All 4 Replies

Well I'm glad hes banned, but can a mod please remove the post completely (edit it out) so that people will still come and contribute to my topic :)

According to marco93 there are piles of tutorials out there already on ODBC. If you do a search on ODBC (Open Database Connectivity) you'll find hundreds of links. So the answer is emphatically YES. I was going to post a tutorial on it too but I won't bother now. See...

http://www.daniweb.com/forums/thread214199.html

Member Avatar for iamthwee

Woah, I don't understand the purpose of this.

Normally you pay for hosting on a website which gives you access to database. Those websites normally run php as the de facto as well.

You can query that database using php and send it back to the client, i.e anyone who accesses that page from their web browser.

So I don't get it. You want to run a c++ app on the same webserver as the one you're hosting from? Doesn't make sense.

But the answer to your question is yes, you can connect to mysql using c++, I believe you just have to install the drivers/(odbc).

Well if the program is going to use Client and Socket servers, the server could just save all related program variables to the local database.

There would be no point, other than a waste of money to pay for the hosting, as well as wasted speed ( latency sending the data to a remote website hosting site ) in order, with this solution.

If I had the database on the same machine as the Server, I would assume all of the data saving and retrieving would be faster.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.