Advertisement
Guest User

Untitled

a guest
May 14th, 2016
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. // ConectSQL.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <mysql.h>
  6. #include <iostream>
  7.  
  8. int main()
  9. {
  10. MYSQL Conect;
  11. mysql_init(&Conect);
  12.  
  13. char cmdSQL[256];
  14. char cliente[] = "Adriano";
  15.  
  16. if (!mysql_real_connect(&Conect, "localhost", "root", "vertrigo", "dbteste", 3306, NULL, 0))
  17. {
  18. printf("Não foi possivel estabelecer uma conexão com o Banco de dados!\n");
  19. mysql_close(&Conect);
  20. system("pause");
  21. return 0;
  22. }
  23. sprintf(cmdSQL, "SELECT * FROM usuarios WHERE login = %s", cliente);
  24. if (!mysql_query(&Conect, cmdSQL)){
  25. printf("ERRO\n");
  26. mysql_close(&Conect);
  27. system("pause");
  28. return 0;
  29. }
  30. printf("%s foi encontrado no banco de dados\n",cliente);
  31. system("pause");
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement