Koneksi borland c++ 5.02 + mysql

/***********************************************************
* Code untuk menghubungkan ke database mysql         *
* created by Dony Wahyu Isp               *
* Doni’X Software (www.donixsoftware.web.id         *
***********************************************************/

#include <stdio.h>
#include <string.h>
#include <mysql.h>

extern char pesan_error[512];
extern int kode_error;

extern char host[32];
extern char user[32];
extern char password[32];
extern char database[32];

//MYSQL mysql;

MYSQL *koneksi_mysql (char* _host, char* _user, char* _password, char* _database, MYSQL *mysql) {

strcpy(host, _host);
strcpy(user, _user);
strcpy(password, _password);
strcpy(database, _database);

mysql_init(mysql);
return mysql_real_connect(mysql, host, user, password, database, 0, 0, 0);
}

void tutup_mysql (MYSQL *koneksi, MYSQL_RES **res) {
mysql_free_result(*res);
mysql_close(koneksi);
}

int eksekusi_sql (unsigned char* sql, MYSQL *koneksi, MYSQL_RES **res) {
int state;
int ch;

state = mysql_query(koneksi, sql);

if (state != 0) {
kode_error = 2;
strcpy(pesan_error, “\nQuery Error!!!\n”);
strcat(pesan_error, mysql_error(koneksi));
return 1;
}

*res = mysql_store_result(koneksi);

return state;
}

MYSQL_ROW list_mysql (MYSQL *koneksi, MYSQL_RES *res) {
return mysql_fetch_row(res);
}

http://forum.vb-bego.com/viewtopic.php?f=36&t=1547

Advertisements