0

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;
}
EdChum
  • 376,765
  • 198
  • 813
  • 562
Julia.G
  • 3
  • 3
  • You can ignore the PDB not found / can not load symbol warnings. These are not errors. They just mean you don't have the symbols to debug inside these dlls. Most likely you will not need that. Unless you think you have found a bug in one of these dlls or your program is causing a crash in one of these dlls and you want to investigate why. – drescherjm Nov 22 '16 at 15:18
  • ***How can I fix it?*** Is there a real error other than these warnings? – drescherjm Nov 22 '16 at 15:21
  • With that said you can in Visual Studio enable the Symbol Server to download the pdb files for windows binaries. I usually don't do that (and just ignore the warnings) because for me it adds minutes to each debug session while the symbol server is processing all the dlls. – drescherjm Nov 22 '16 at 15:23
  • I've answered this issue many times. Search the internet for "stackoverflow c++ mysql connector". You should always search the internet before posting. – Thomas Matthews Nov 22 '16 at 15:28
  • Does your program execute? Does you program need an account created in MySQL? – Thomas Matthews Nov 22 '16 at 15:30
  • Connection failed eventhough I have made this database in my SQLServer. Also after realease window is opening just for a second and closing right away, how can I change it? – Julia.G Nov 22 '16 at 15:34
  • ***Also after realease window is openning just for a second and closing right away, how can I change it?*** That is a very common problem for people new to Visual Studio. There are thousands of duplicates for that on SO. – drescherjm Nov 22 '16 at 15:35
  • Yes, I have created account in mySQL., – Julia.G Nov 22 '16 at 15:35
  • Here is a duplicate about keeping the console window open: http://stackoverflow.com/questions/454681/how-to-keep-the-console-window-open-in-visual-c – drescherjm Nov 22 '16 at 15:36
  • Thank you drescherjm, you helped me a lot! – Julia.G Nov 22 '16 at 19:29

0 Answers0