'Access violation reading' when changing db
Posted by: Crabby nolastname
Date: June 24, 2010 05:37PM


I have an "access violation reading" error when i try to change database.
The default code works fine, I can change tables, fields but when i change db it spits out
"..0xC0000005: Access violation reading location 0x0000000c."

. I tried copying database "mysql" to "myssql" just to check things out.., but still couldn't select from it (myssql) ..
#include "stdafx.h"

#include <stdlib.h>
#include <iostream>
#include <stdio.h>
#include <stdarg.h>
#include <windows.h>
#include <mysql.h>

MYSQL *mysql;
MYSQL_RES *results;
MYSQL_ROW record;

static char *server_options[] = { "mysql-test", "--datadir=D:/softdev/testprojects/002_themysqlserv/data",
"--language=C:/Server/MySQL/share/english", NULL };

int num_elements = sizeof(server_options)/ sizeof(char *) - 1;

static char *server_groups[] = { "libmysqld_server", NULL };

int main(int argc, char* argv[])
{ int retval;
retval = mysql_library_init(num_elements, server_options, (char **) server_groups);
mysql = mysql_init(NULL);
mysql_real_connect(mysql, NULL, "root", NULL, "mysql", 0, NULL, 0);
// mysql_real_connect(mysql, NULL, "root", NULL, "myssql", 0, NULL, 0);
mysql_query(mysql, "SELECT name FROM help_topic");
results = mysql_store_result(mysql);

/*error*/ while((record = mysql_fetch_row(results))) {
printf("%s – %s \n", record[0], record[1]);

return 0;

I followed this guide http://lstigile.wordpress.com/2009/05/19/using-libmysqld-with-microsoft-visual-c-2008-express/

Im using VS2010..

I'm probably missing something.. Point me in the right direction :)


Edited 1 time(s). Last edit at 06/24/2010 05:45PM by Crabby nolastname.

Options: ReplyQuote

Written By
'Access violation reading' when changing db
June 24, 2010 05:37PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.