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;
}
Comments
Nice going.

Whoa ! it worked, Thank you mitrmkar.

daviddoria > Yes, it should be capitalized.

Thank you both of you!

This question has already been answered. Start a new discussion instead.