SQL External errors? :(

So I followed the tutorial on this site
http://codedev.info/how-to-connect-mysql-and-c/

but in the end I got external errors just by adding something from mysql
mysql_init(&mysql);

Here's the error message:
1
2
3
4
5
6
7
8
9
'mysqlDBinjector.exe': Loaded 'C:\Users\Monckey100\Documents\Visual Studio 2010\Projects\mysqlDBinjector\Release\mysqlDBinjector.exe', Symbols loaded.
'mysqlDBinjector.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'mysqlDBinjector.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'mysqlDBinjector.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'mysqlDBinjector.exe': Loaded 'C:\Windows\SysWOW64\msvcp100.dll', Cannot find or open the PDB file
'mysqlDBinjector.exe': Loaded 'C:\Windows\SysWOW64\msvcr100.dll', Cannot find or open the PDB file
The thread 'Win32 Thread' (0xb04) has exited with code -1073741510 (0xc000013a).
The program '[2576] mysqlDBinjector.exe: Native' has exited with code -1073741510 (0xc000013a).



A real kick in the butt, I don't mind posting my full code but it is messy.
Without seeing anything else, it looks like the problem is you're debugging while in Release mode and/or you don't have a debug version of the mysql library. Try running without debugging.

EDIT: on second thought the problem might be that you have a mysql library that targets a 32 bit platform as opposed to a 64 bit one.
Last edited on

shacktar (1026) Apr 13, 2012 at 7:29pm
Without seeing anything else, it looks like the problem is you're debugging while in Release mode and/or you don't have a debug version of the mysql library. Try running without debugging.

EDIT: on second thought the problem might be that you have a mysql library that targets a 32 bit platform as opposed to a 64 bit one.


It might be debugging in release mode...the program would work without the mysql components...I don't have the debug version of the mysql library installed, coudl that be the issue? How would I run without debugging?

I originally installed 64bit but that caused bigger issues and wouldn't compile at all
How would I run without debugging?

Select Debug -> Start without debugging

I did a little searching and apparently your problem could be due to having insufficient access privileges. Try starting Visual Studio with administrator privileges (right click, run as administrator) then run your program and see if that fixes it.
Well running as administrator did seem to clean up SOME errors

1
2
3
4
5
'mysqlDBinjector.exe': Loaded 'C:\Users\Monckey100\Documents\Visual Studio 2010\Projects\mysqlDBinjector\Release\mysqlDBinjector.exe', Symbols loaded.
'mysqlDBinjector.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'mysqlDBinjector.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'mysqlDBinjector.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
The program '[5008] mysqlDBinjector.exe: Native' has exited with code -1073741701 (0xc000007b).


Sadly I couldn't find the start without debugging, I'm running it under release mode if that's what you mean...I have also tried opening the build from the release folder, it just opens and closes and I already isolated it to being mysql that is causing the error
I couldn't find the start without debugging

In the main menu, there's "Debug". Under that, there's the option "Start Without Debugging". Ctrl + F5 also does the trick.

It won't hurt if you post the code.

One thing you could try is building for a different platform (if you're currently building for 32 bit, then build for 64 bit and vice versa).

Another thing is perhaps the dll(s) required by the mysql library aren't being found. I would download dependency walker (depends.exe) and run it on libmysql.dll and see if all its required dlls are accessible to your program. Also, are you sure libmysql.dll is accessible to your program (i.e. is it in the same directory or on the system path somewhere)?
Running without debug at least launches the program but the issue still remains..I'll paste the code...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// mysqlDBinjector.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <my_global.h>
#include <mysql.h>
#include <string>
using namespace std;
MYSQL *connection, mysql;
MYSQL_RES *result;
MYSQL_ROW row;
int query_state;

int _tmain(int argc, _TCHAR* argv[])
{

char finish;
	string DBname;
	string USERname;
	string password;
	cout << "hi";
	cin >> DBname;
	mysql_init(&mysql);
	connection = mysql_real_connect(&mysql,"localhost","root","alphamaletax1234567890!@#$%DASDczxfr","test",0,0,0);
	if(connection == NULL){
		cout << mysql_error(&mysql) << endl;
		return 1;
	}
	else {
		string DOIT =  "CREATE DATABASE " + DBname + "; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON " + DBname + ".* TO '" + USERname + "'@'localhost' IDENTIFIED BY '" + password + "';";
		query_state = mysql_query(connection, DOIT.c_str());
		if (query_state != 0) {
			cout << mysql_error(connection) << endl;
			return 1;
		}
		else {
			result = mysql_store_result(connection);
			while ((row = mysql_fetch_row(result)) != NULL ) {
				cout << row[0] << endl;
			}
		}
		cout << "Done? Y/N" << endl;
		cin  >> finish;
		if (finish == 'Y'){
		mysql_free_result(result);
		mysql_close(connection);
		}
	}
	cout << "test";
	system("pause");
	return 0;
}
Are you sure libmysql.dll is accessible to your program? Did you place it in the same directory as your .exe? Or, is it in your system directory (system32 or sysWOW64)?
I have stuck it in every single directory of the project file...and in my system32/sysWOW64 directory...still nothing :|

It just says press any key to continue, I even added a printf("hello world"); after line 50 to see if it was perhaps the cout/cin...still nothing

Commenting out the mysql stuff makes the program properly read though
It probably won't help but you could try making a new project, an "Empty Project" instead of a console project, to get rid of the need to include "stdafx.h" and to use int main() instead of int _tmain.

The only thing I can think of is that you're linking with the wrong library. Try compiling/linking/running with the other versions of this library.

The other thing I would do is to start a debug session with a breakpoint on mysql_init. Try stepping over it to be certain that it's causing the crash.

We're running out of options here :s
I did the empty project thing, same result...
What do you mean by other versions of the library, so reinstall mysql's older versions?

How would I go about creating a breakpoint for the mysql_init?
What do you mean by other versions of the library

I mean try it with the other versions of the library available here:
http://dev.mysql.com/downloads/connector/cpp/

Note that there are four versions of the library there, 32 bit, 32 bit VisualStudio 2005, 64 bit, and 64 bit Visual Studio 2005. You said earlier that you tried it with the 64 bit version but that it wouldn't compile. Are you sure you changed the platform to 64 bit before compiling?

How would I go about creating a breakpoint for the mysql_init?

In the code editor you'll notice a grey strip going down the left. If you click there, a red dot should appear next to the line of code. What you should do is click next to the call to mysql_init to place the red dot (breakpoint) on that line. Next, run with debugging. The debugger should show a yellow arrow next to the call to mysql_init, indicating that this line will be the next to execute. Press F10 to step over this line (i.e. it will execute mysql_init). If that function is indeed causing the problem, the debugger should stop and/or show you an error. I would suggest Googling how to debug with Visual Studio for more info.
Last edited on
Topic archived. No new replies allowed.