Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConectSQL.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <mysql.h>
- #include <iostream>
- int main()
- {
- MYSQL Conect;
- mysql_init(&Conect);
- char cmdSQL[256];
- char cliente[] = "Adriano";
- if (!mysql_real_connect(&Conect, "localhost", "root", "vertrigo", "dbteste", 3306, NULL, 0))
- {
- printf("Não foi possivel estabelecer uma conexão com o Banco de dados!\n");
- mysql_close(&Conect);
- system("pause");
- return 0;
- }
- sprintf(cmdSQL, "SELECT * FROM `usuarios` WHERE `login` = '%s'", cliente);
- if (!mysql_query(&Conect, cmdSQL)){
- printf("ERRO\n");
- mysql_close(&Conect);
- system("pause");
- return 0;
- }
- printf("%s foi encontrado no banco de dados\n",cliente);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement