Advertisement

[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

02/09/2005 at 08:37AM PST, ID: 21308091
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

Trying to connect to MySQL from Visual C++ 6 (Windows MFC Application)

Asked by poisa in Windows MFC Programming

Tags: mysql, connect, visual

Trying to connect to MySQL from Visual C++ 6 (Windows MFC Application)

Hi,

I'm trying to connect to a MySQL database from C++. First I downloaded mysql++-1.7.28.tar.gz from here --> http://tangentsoft.net/mysql++/. I then copied this to some folder and added it to the Visual C++ inlcude directories

After browsing through the forums, I found this code:


#include "stdafx.h"
#include <mysql.h>


int main()
{

// create a pointer of the type mysql
MYSQL *conn;
// initialize your mysql connection
conn = mysql_init(NULL);
// connect to your database
mysql_real_connect(conn,"localhost","username","password","database",0,NULL,0);
// perform a query
mysql_query(conn,"UPDATE my_table SET somevalue = somevalue + 1 WHERE id = 5");
// close the connection
mysql_close(conn);

 return 0;
}

But it seems that I don't have the mysql.h file, as this returns "fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory"

I then downloaded the MySQL Windows source files from here --> http://dev.mysql.com/downloads/mysql/4.1.html and found the necessary file inside. I copied this file to the include dir and asks for two other files: mysql_com.h, and mysql_version.h, which I proceed to copy also to the specified dir. After this, I compile again and get:

error C2146: syntax error : missing ';' before identifier 'fd'
error C2501: 'SOCKET' : missing storage-class or type specifiers
error C2501: 'fd' : missing storage-class or type specifiers

Can anyone give me some pointers on this one?

Bare in mind that I'm starting out with C++ and don't fully understand the terminology, so try to keep it simple.
My main objective is to create an MFC Application, but I figure that if I can get a Win32 Console App to connect to the db, then the rest is downhill.

Thanks.

PS: I also tried this other API (http://mysqlcppapi.sourceforge.net/) without any success.View the Solution FREE for 30 Days
 
Keywords: Trying to connect to MySQL from Visu…
Title
1 MySql very slow
 
Loading Advertisement...
 
[+][-]02/09/05 08:57 AM, ID: 13266118

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02/09/05 09:00 AM, ID: 13266154

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/09/05 09:04 AM, ID: 13266204

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/09/05 09:08 AM, ID: 13266253

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/09/05 09:19 AM, ID: 13266388

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02/09/05 09:33 AM, ID: 13266558

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/09/05 10:03 AM, ID: 13266906

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Windows MFC Programming
Tags: mysql, connect, visual
Sign Up Now!
Solution Provided By: jaime_olivares
Participating Experts: 3
Solution Grade: A
 
 
[+][-]02/09/05 10:04 AM, ID: 13266918

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/09/05 11:59 AM, ID: 13268397

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/09/05 12:23 PM, ID: 13268685

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/09/05 12:32 PM, ID: 13268784

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20090429-EE-VQP-58