Errors connecting to MySQL 4.0.15
//1. I'm trying to connect to MySQL 4.0.15 using Visual C++ 6.0. This is the sample code that I'm using. I'm just simply trying to connect and query the database:
#include<iostream.h>
#include<winsock.h>
#include<mysql.h>
#include<windows.h>
#include<stdio.h>
#define host "C:\mysql\bin\mysql.exe"
#define user "Enrique0822"
#define password "xxxxx"
#define database "Numberlyzer"
MYSQL *conn;//pointer to active database
int main()
{
conn = mysql_init(NULL);
mysql_real_connect(conn,host,user,password,databas
e,0,NULL,0);//connects you to the database.
MYSQL_RES *result;//varible to return a result
MYSQL_ROW row;//variable to return row
unsigned int i;//variable to increment in the loop in case more than one row is returned
unsigned int n;
mysql_query(conn,"SELECT * FROM pic3");//query the database
result = mysql_store_result(conn);//store result in the result variable
n = mysql_num_rows(result);//variable that will allow you to loop through the number of rows returned
while ((row = mysql_fetch_row(result)) != NULL)
{
for (i=0; i<mysql_num_fields(result); i++)
{
printf("%s\n",row[i] != NULL ? row[i] : "NULL");
}
}
mysql_close(conn);
return 0;
}
//2. I also double checked to make sure that I included the mysql++.lib file under project settings link tab. Maybe someone has a better set of eyes than I do but the code looks good to me. When I try to compile I get the following 3 errors:
--------------------Configuration: database - Win32 Debug--------------------
Compiling...
database.cpp
c:\mysql\database\database.cpp(25) : warning C4129: 'm' : unrecognized character escape sequence
c:\mysql\database\database.cpp(25) : warning C4129: 'm' : unrecognized character escape sequence
c:\mysql\database\database.cpp(36) : warning C4244: '=' : conversion from 'unsigned __int64' to 'unsigned int', possible loss of data
database.obj - 0 error(s), 3 warning(s)
//3. The program allows me to link inspite of these warnings. But when I attempt to run the program, it simply crashes. When this happens I try to debug the error and a popup window in the debugger generates the following message:
Unhandled exception in database.exe (LIBMYSQL.DLL) : 0x0000005: Access Violation
//4. I'm not sure if this part is relevant but after I click ok on the popup windows message, I see the following messages displayed under the debug window tab:
Loaded symbols for 'C:\mysql\Database\Debug\database.exe'
Loaded 'C:\WINDOWS\system32\ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\libmySQL.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wsock32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ws2_32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msvcrt.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ws2help.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\advapi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\mswsock.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\dnsapi.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\winrnr.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wldap32.dll', no matching symbolic information found.
Loaded 'C:\Program Files\NewDotNet\newdotnet4_88.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\user32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\gdi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ole32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\oleaut32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wininet.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\SHLWAPI.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\crypt32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msasn1.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\imm32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\lpk.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\usp10.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.10.0_x-ww_f7fb5805\comctl32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\rasadhlp.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\comctl32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wshtcpip.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\version.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\apphelp.dll', no matching symbolic information found.
The thread 0x9A0 has exited with code 0 (0x0).
//5. In case anyone is wondering I'm using Windows XP and I downloaded the MySql++ API version 1.7.1. Any help would be greatly appreciated. I'm pretty good with SQL and C++ programming but I just can't seem to get them to work together:-(