[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

mySQL with C++

Posted on 2001-07-02
9
Medium Priority
?
425 Views
Last Modified: 2008-03-06
Okay, I'm pretty new to C++ here, so y'all might have to speak in newbie terms or I'll get lost!

Basically, I want to start using C or C++ to access a mySQL database. I'll set up a little scenario for the purpose of this question...

I have a mySQL table set up with three fields, X, Y and Z. I want my C++ program to read in the three values, then multiply X by Y, and increment the value of Z by this figure.

I then want to update the database.

I tried to install the API available on mySQL.com but failed miserably, so I could do with a step-by-step guide for this too. I use the Borland C++ Compiler (5.5).

Thanks in advance,

Stephen Sherlock
0
Comment
Question by:stesherlock
9 Comments
 

Expert Comment

by:le
ID: 6248580
The simpliest way to do what you want is to use ODBC driver, which comes with mySQL. Install it. Then using ODBC32 tool from controll pannel. COnfigure it to point to proper mySQL database. I do not know too much about Borland 5.5 but it may have some odbc related classes build in. Also many freeware C++ ODBC wrappers are avaliable.
0
 

Author Comment

by:stesherlock
ID: 6252411
Okay, I can use ODBC (played with it before so I could access my mySQL DB via MS Access before I found a little program called mySQL-Front) but I'd need some help on using C++ to access the DB via ODBC...
0
 
LVL 1

Expert Comment

by:CSLIU
ID: 6254262
MSDN on-line help (ODBC):
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlconnect.asp

there are many ways.

1,database <-> ODBC <-> App.
2,database <-> ODBC <-> ADO(OLE DB) <-> App.
3,database <-> ODBC <-> DAO <-> App.
4,database <-> ODBC <-> BDE(Borland Database Engine) <-> App.



0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:stesherlock
ID: 6257917
I've heard that ODBC is a little slow though, and my eventual project is going to need optimisation. Is it relatively easy to access mySQL directly from C++?
0
 

Expert Comment

by:sumansamanta
ID: 6258624
ODBC is quit good for accessing global data, but since its purpose is to access heterogenous database, it may not be as optimized as native data access APIs provided by particular Database vendors (like OCI for Oracle, DB Library for Sybase, DAO for MS Access). I don't know whether that kind of native API is available for MYSQL or not ?

   But I still think you should use ODBC as your database access tool, because it is most commonly used for windows platform and most well documented. You can seek help from MSDN or Microsoft's site (www.microsoft.com for MSDN online), in this issue. A well written program using ODBC is good enough in speed and is not that slow , as you are thinking. Plus you have the added advantage that, if in future you decide to change your backend (say from MYSQL to Oracle) then no changes or may be very little changes are required in your C/C++ code.

You can visit some sites like www.codeguru.com for sample codes.
0
 
LVL 1

Expert Comment

by:CSLIU
ID: 6260294
> I've heard that ODBC is a little slow though, and my
> eventual project is going to need optimisation.
> Is it relatively easy to access mySQL directly from C++?

yes.

http://www.mysql.com/downloads/api-mysql++.html

or

http://www.mysql.com/Downloads/mysql++/mysql++-1.7.1-win32-borland.zip

0
 
LVL 1

Accepted Solution

by:
CSLIU earned 600 total points
ID: 6260321
> I tried to install the API available on mySQL.com but
> failed miserably, so I could do with a step-by-step
> guide for this too. I use the Borland C++ Compiler (5.5).

what's the problem?
0
 
LVL 11

Expert Comment

by:griessh
ID: 6825264
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to accept "CSLUI" comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points.
The link to the Community Support area is: http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 

Author Comment

by:stesherlock
ID: 6829307
Sorry for forgetting about you peeps, very long sotry though...

I'll give the points to CSLIU, but I don't use C++ these days (don't have the time) so I never even got to try any of these solutions :(
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question