Thanks - I have the database installed and I also have the Connector/C installed. You're awesome... Thanks so much. Thomas On 2/21/11 1:28 AM, "Robert Purves" <listrp@...> wrote: > >Thomas Peters wrote: > >> 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> > > >You would first have to obtain and install mysql, because it is not part >of OS X. >Then something like this should compile (but with link-time errors): > >'-------------- >include "CommandLineTool" > >BeginCDeclaration >#include <mysql/mysql.h> >#include <stdio.h> >#include <string.h> > >int Test(); >EndC > >BeginCFunction >int Test() >{ >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,NU >LL,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; >} >EndC > >toolbox fn Test = SInt32 > >// main >fn Test >'-------------- > >Lastly, for correct linking you will need to put a link option in 'More >compiler options' in FBtoC settings. This may be as simple as -lmysql. > >Robert P. > > >-- >To unsubscribe, send ANY message to: futurebasic-unsubscribe@... >To access the list archives, go to: >http://freegroups.net/groups/futurebasic/ > >