koneksi Borland 5.02 C++ dgn MySQL

Posted: April 11, 2011 in Uncategorized

/***********************************************************
* Code untuk menghubungkan ke database mysql         *
* created by Dony Wahyu Isp               *
* post by ibnu…
* 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

Comments
  1. aku mau tnya donk,,
    aku kan buat program simple biodata
    trus cara koneksi ke mysqlnya gmn ya??
    codingnya jg gmn??
    thx

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s