Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
here is my c program to connect to my sql server
C#
#include <my_global.h>
#include <mysql.h>

int main(int argc, char **argv)
{
  MYSQL *con = mysql_init(NULL);

  if (con == NULL)
  {
      fprintf(stderr, "%s\n", mysql_error(con));
      exit(1);
  }

  if (mysql_real_connect(con, "localhost", "root", "root_pswd",
          NULL, 0, NULL, 0) == NULL)
  {
      fprintf(stderr, "%s\n", mysql_error(con));
      mysql_close(con);
      exit(1);
  }

  if (mysql_query(con, "CREATE DATABASE testdb"))
  {
      fprintf(stderr, "%s\n", mysql_error(con));
      mysql_close(con);
      exit(1);
  }

  mysql_close(con);
  exit(0);
}
Posted
Updated 13-Feb-14 7:27am
v3
Comments
Jochen Arndt 13-Feb-14 8:59am    
And what is the problem?
Do you want to know how to run your C compiler?
This depends on the compiler you want to use. You should tell us which compiler you want to use and the operating system you are using.
Jochen Arndt 14-Feb-14 5:23am    
The question is still unclear.

If you have created a project, just click the build option in the toolbar or activate the corresponding menu option.

For specific questions about the Pelles compiler and IDE, you should register at the Pelles forum: http://forum.pellesc.de/.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900