Solved

mySQL with C++

Posted on 2001-07-02
9
400 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

732 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