I want to connect to database in MySQL Server using program in C++ in Visual Studio 2015. Last two weeks I was trying to solve this problem and still I am not able to do that.
What I have: Visual Studio 2015, MySQL Server 5.7 (installation from 32 bin, but it has note: "MySQL Installer is 32 bit, but will install both 32 bit and 64 bit binaries".), Connector.C++ 1.1 (64 bit), Windows 10
I have a problem with connecting mysql.h to my program. I have done all steps as it was described here: http://dev.mysql.com/doc/connector-cpp/en/connector-cpp-apps-windows-visual-studio.html but still have next problems. I try to open it in Release Configuration x64 and get this:
"Connection.exe" (Win32). Загружено "C:\Windows\System32\ntdll.dll". Невозможно найти или открыть PDB-файл. (In translation: Cannot find or open PDB-file)
"Connection.exe" (Win32). Загружено "C:\Windows\System32\kernel32.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\KernelBase.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\ucrtbase.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\msvcp140.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Users\YULIA\Desktop\App1\Connection\x64\Release\libmysql.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\vcruntime140.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\advapi32.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\msvcrt.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\secur32.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\sechost.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\rpcrt4.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\ws2_32.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\sspicli.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\NapiNSP.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\pnrpnsp.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\nlaapi.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\mswsock.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\dnsapi.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\nsi.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\IPHLPAPI.DLL". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\winrnr.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\wshbth.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\rasadhlp.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\FWPUCLNT.DLL". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\bcrypt.dll". Невозможно найти или открыть PDB-файл.
"Connection.exe" (Win32). Загружено "C:\Windows\System32\kernel.appcore.dll". Невозможно найти или открыть PDB-файл.
How can I fix it?
This is my code:
#include "stdafx.h"
#include <iostream>
#include <Winsock2.h>
#include <mstcpip.h>
#include <mysql.h>
#pragma comment(lib,"libmysql.lib")
#pragma comment(lib,"mysqlclient.lib")
using namespace std;
// Defining Constant Variables
#define SERVER "localhost"
#define USER "root"
#define PASSWORD ""
#define DATABASE "test"
int main()
{
MYSQL *connect;
connect = mysql_init(NULL);
if (!connect)
{
cout << "Mysql Initialization Failed";
return 1;
}
connect = mysql_real_connect(connect, SERVER, USER, PASSWORD, DATABASE, 0, NULL, 0);
if (connect)
{
cout << "Connection Succeeded\n";
}
else
{
cout << "Connection Failed\n";
}
mysql_close(connect);
return 0;
}