Valerio,
It seems to me, that you need to init (mysql_init) serveral
times; I have not tried this but I would try the following:
MYSQL conn1, conn2, conn3;
conn1 = mysql_init(NULL)
if ( mysql_real_connect(conn1, ip1, user1, pass1, db1, 0, NULL, 0)
== NULL )
some error happened.
printf("conn1= %d", conn1)
con2 = mysql_init(NULL)
if ( mysql_real_connect(conn2, ip1, user1, pass1, db1, 0, NULL, 0)
== NULL )
some error happened.
printf("conn2= %d", conn1)
conn3 = mysql_init(NULL)
if ( mysql_real_connect(conn3, ip1, user1, pass1, db1, 0, NULL, 0)
== NULL )
some error happened.
printf("conn3 = %d", conn1)
Let me know if it works,
-Teresa
> -----Original Message-----
> From: Valerio Ferrucci [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, January 12, 2001 8:32 AM
> To: [EMAIL PROTECTED]
> Subject: MySQL C API multiple connections
>
> Hi,
> I'm building a MySQL C API client. I need to connect to different dbs
> at the same time. My code is (approximately):
>
> //============================
> MYSQL mysql, *conn1, *conn2;
>
> mysql_init(&mysql)
>
> conn1 = mysql_real_connect(&mysq, ip1, user1, pass1, db1, 0, NULL, 0)
> printf("conn1 = %d", conn1);
>
> conn2 = mysql_real_connect(&mysq, ip2, user2, pass2, db2, 0, NULL, 0)
> printf("conn2 = %d", conn1);
>
> conn3 = mysql_real_connect(&mysq, ip3, user3, pass3, db3, 0, NULL, 0)
> printf("conn3 = %d", conn3);
>
> // ... use conn1
> // ... use conn2
> // ... use conn3
>
> mysql_close(conn1);
> mysql_close(conn2);
> mysql_close(conn3);
>
> mysql_close(&mysql);
> //============================
>
> I see always that (conn1 == conn2), so the first connection is lost.
> Could you give some explanation about this?
> How can I mantain different connections on different db (ip, user,
> etc....)?
>
>
>
> ==================================================================
> Valerio Ferrucci Tabasoft Sas
> [EMAIL PROTECTED] http://tabasoft.ancitel.it
> [EMAIL PROTECTED]
>
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php