Hmm i actually got it to work. I can now connect through a VB6 project
But i still cant send a query, it still crashes when i try to send a query, but it also crashes within a C++ project, so i think its a problem with my function. Also, it does not seem to return the "returns" in my VB project. And it also shows an error after i close the VB program after i use the connect function.
This is my code:
Code:
#include "stdafx.h"
#include <winsock.h>
#include <mysql.h>
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
char* __stdcall mysql_connect(char *server, char *user, char *password, char *database);
char* __stdcall mysql_sendquery(char *query);
char** __stdcall mysql_fetch_row();
char* __stdcall mysql_closeconn();
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
char* __stdcall mysql_connect(char *server, char *user, char *password, char *database) {
conn = mysql_init(NULL);
if (!mysql_real_connect(conn, server, user, password, database, 0, NULL, 0)) {
return "Error connecting";
}
return "Connected";
}
char* __stdcall mysql_sendquery(char *query) {
if (mysql_query(conn, query)) {
return "Error with query";
}
return "Query successfull";
}
char** __stdcall mysql_fetch_row() {
char** error;
error[1] = "Error fetching row";
res = mysql_use_result(conn);
while ((row = mysql_fetch_row(res)) != NULL) {
return row;
}
return error;
}
char* __stdcall mysql_closeconn() {
mysql_close(conn);
return "Connection closed";
}