6 messages in com.mysql.lists.plusplusRe: Re: how to connect borland c++ wi...
FromSent OnAttachments
raj kumar15 Nov 2002 06:21 
Gelu Gogancea15 Nov 2002 07:59 
raj kumar15 Nov 2002 08:35 
Gelu Gogancea15 Nov 2002 09:59 
Gelu Gogancea15 Nov 2002 10:47 
Christian Jeworrek15 Nov 2002 12:16 
Subject:Re: Re: how to connect borland c++ with mysql server in windows
From:Gelu Gogancea (gge@arctic.ro)
Date:11/15/2002 10:47:22 AM
List:com.mysql.lists.plusplus

Hi,

An example of how you can connect to MySQL and retrieve data: #include <windows.h> #include <stdio.h> #include <string.h> #include "C:\MySQL\include\mysql.h"

int main() { MYSQL *myData ; MYSQL_RES *res; MYSQL_ROW row; char msql[2048]; int j,k;

if ((myData = mysql_init((MYSQL*) 0)) && mysql_real_connect( myData, "10.0.0.34", "root", "", "", MYSQL_PORT, NULL, 0 ) ) { mysql_select_db(myData,"mysql"); } else { printf("Fsss connection...\n"); return 1; }

strcpy(msql,"select * from user;");

int a=mysql_real_query(myData,msql,strlen(msql)); res=mysql_store_result(myData);

row = mysql_fetch_row( res ); //fetch the ROW

j = mysql_num_fields( res ) ; for ( k = 0 ; k < j ; k++ ) { printf(" %s ",row[k]); }

mysql_free_result( res ) ;

mysql_close(myData);

return 0; } Regards,

Gelu

_____________________________________________________ G.NET SOFTWARE COMPANY

Permanent e-mail address : gg@gonetsoftware.com gelu@yahoo.com

thanks for the location but I thinks you got me wrong.... I know how to compile C program in linux . but in windows I am using BC++ borland version 5.*. In windows-2000 I am running mysql server on the same machine I want to connect my C/C++ program with the DB. here it first require mysql.h when I copy all the mysql server's file placed in mysql dir and all ther lib files from server source to borland folder's lib directory and try to compile it compile successfully but it does not run and give error like externel refrece to "mysql_init", "mysql_connect" "mysql_close" does not find .. and shows linking error in object file (test.obj of test.c)..... if you understand my problem please response me whether I need some ODBC connectivity of it...

one last thing I want to connect windows borland-5.0 C++ program with mysql server running on linux machine If it can be done please hint me little bit on that too.

thanks a lot..

On Fri, 15 Nov 2002 Gelu Gogancea wrote :

Hi, If you wish to use MySQL API : http://www.mysql.com/doc/en/C.html Regards,

Gelu

_____________________________________________________ G.NET SOFTWARE COMPANY

Permanent e-mail address : gg@gonetsoftware.com

gelu@yahoo.com

hello tp you all , can anybody help me out there to connect the mysql database with BC++ 5.* Please provide me some web page location where I can find info,understandable to beginners in mysql... thanks for it... raj India