贴段代码给你(可不是我写的o)
/*
Name: MySQLClientTest
Author: Kip Warner (kip@zero47.com)
Date: 24/11/03 13:15
Description: Example to show usage of MySQL databases from client end.
I did not have much time. Sorry...
*/
// Connect to server and check for error...
if(mysql_real_connect(myDatabase, g_szHost, g_szUserName, g_szPassword,
NULL, g_unPort, NULL, 0) != 0)
{
// Alert user...
printf("] Error: Unable to connect to server...\n");
// Select database in server and check for error...
if(mysql_select_db(myDatabase, g_szDatabase) < 0)
{
// Alert user...
printf("] Error: Unable to select database...\n");