I successfully configured MYSQL with VS2008, i executed the following code, and no errors were thrown.

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

void main()
{

   
}

Now i need to write a C++ code to retrieve some values from a Database, therefore i used the following code;

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


void main()
{
MYSQL *conn;
   
}

As soon as i type MYSQL *conn; and run the application i get the following error message;

error C2065: 'MYSQL' : undeclared identifier

There's just something missing here, and google couldn't give a good solution, Please help.

Are you sure its supposed to be capitalized? The name of the header is 'mysql', so I would try mysql *conn;

Quite likely your project is configured to use precompiled headers through "stdafx.h".
In other words, you'll need to change the order of your includes, in order for the compiler to see <mysql.h>.

You could try ..

#include "stdafx.h" // First stdafx.h

#include <cstdio>
#include <windows.h>
#include <mysql.h>

int main()
{
  MYSQL *conn;
}
commented: Nice going. +5

Whoa ! it worked, Thank you mitrmkar.

daviddoria > Yes, it should be capitalized.

Thank you both of you!

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.