Advertisement
Guest User

Conexão Mysql em C

a guest
Apr 13th, 2015
1,312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <windows.h>
  3. #include <winsock2.h>
  4. #include <mysql.h>
  5.  
  6.  
  7. int main()
  8. {
  9.     MYSQL conexao;
  10.     mysql_init(&conexao);
  11.     if ( mysql_real_connect(&conexao, "endereço", "usuário", "senha", "banco de dados", 0, NULL, 0) )
  12.     {
  13.        printf("\nConexao ao banco realizada com sucesso!\n");
  14.     }
  15.     else
  16.     {
  17.         printf("Falha de conexao\n");
  18.         printf("Erro %d : %s\n", mysql_errno(&conexao), mysql_error(&conexao));
  19.     }
  20.     system("PAUSE");
  21.     return(0);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement