[futurebasic] anyone know how to make this work in FB

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2011 : Group Archive : Group : All Groups

From: Thomas Peters <thomasg_peters@...>
Date: Sun, 20 Feb 2011 23:18:42 -0500
This is a simple snippet of C code to test a connection to MySQL database.
 It uses the native C API from MySQL library.  I am interested in learning
how this can be converted into a FB Function.  I noticed the WebServices
example uses BeginCFunction >> EndC code block.

<snip>

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

int main() {    
    MYSQL mysql;
    MYSQL_RES *res;
    MYSQL_ROW row;
    char query[80];
    mysql_init(&mysql);
    
mysql_real_connect(&mysql,"some.host.com","ipaudit","letmein","audit",0,NUL
L,0);
    sprintf(query,"SELECT src,dst FROM ipaudit");
    mysql_real_query(&mysql,query,(unsigned int)strlen(query));
    res = mysql_use_result(&mysql);

    while(row = mysql_fetch_row(res))
     printf("%s %sn",row[0],row[1]);

    mysql_free_result(res);
    return 0;
 } 

</snip>