dbTalk Databases Forums  

help to connect from c application

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss help to connect from c application in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Elizabeth Bonifacio
 
Posts: n/a

Default help to connect from c application - 06-22-2005 , 05:07 AM






I'm new into mysql and has been encountering huge problem in
connecting to the database from the c application. Error message is:
Failed to connect to database: Error:
Client does not support authentication protocol requested by server;
consider upgrading MySQL client
Press any key to continue

here is the application:
#include "stdio.h "=20
#include "winsock.h"=20
#include "iostream.h "

#include "mysql.h"

int main()
{=20

MYSQL mysql;=20
MYSQL_ROW row;=20
MYSQL_RES *result;=20

unsigned int num_fields;=20
unsigned int i;=20
int num =3D 0;
int iRetValue =3D 0;

mysql_init(&mysql);=20
//printf("%s",&mysql );

if (!mysql_real_connect(&mysql,"localhost","sampadm", "secret","sampdb",3306=
,
NULL,0))
{=20
fprintf(stderr, "Failed to connect to database: Error: \n%s\n",=20
mysql_error(&mysql));=20
}=20
else=20
{=20
printf("SUCCESS\n");
iRetValue =3D mysql_query(&mysql, "SELECT * FROM user");

if( iRetValue !=3D 0 )
{
printf("Query Not Executed Properly.Please Check The Syntax.\n");
}
//here goes the error message )=20
else
{=20
result =3D mysql_store_result(&mysql);

num =3D mysql_field_count(&mysql);
printf("Number Of Rows :%d\n",num );

num_fields =3D mysql_num_fields( result);
printf("Number Of Coloumns :%d\n",num_fields );

while ((row =3D mysql_fetch_row(result)))=20
{=20
unsigned long *lengths;=20
lengths =3D mysql_fetch_lengths(result);=20

for(i =3D 0; i < num_fields; i++)=20
{=20
printf("[%.*s] \t", (int) lengths[i], row[i] ? row[i] : "NULL");=20
}=20
printf("\n");=20
}=20
}=20
}
}=20

I would appreciate if you guys can help. thanks.

Elizabeth

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.