469,607 Members | 2,207 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,607 developers. It's quick & easy.

Borland C++ and MySQL connection problem

2
Hi everybody;

I am trying to connect to MySQL server over MySQL ODBC 3.51 driver. Borland C++ 5.02 is the tool I use.

I tried a simple connection code below:

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "mysql.h"
  4.  
  5. MYSQL mysql;
  6. int dum;
  7.  
  8. int main()
  9. {
  10.     mysql_init(NULL);
  11.  
  12.     if (!(mysql_real_connect(&mysql,"localhost","onur","pass","mysql",0,NULL,0)))
  13.     {
  14.         printf("Connection failed.");
  15.         scanf(" %d",dum);
  16.     }
  17.     else
  18.     {
  19.         printf("Connected.");
  20.         scanf(" %d",dum);
  21.     }
  22.  
  23.     mysql_close(&mysql);
  24.     return 0;
  25. }
There are three errors with this code:

mysql_com.h( 184, 15 ) : Type name expected
mysql_com.h( 184, 15 ) : Declaration missing ;
mysql_com.h( 354, 26 ) : 'SOCKET' cannot start a parameter declaration

Could anyone help me?
Thanks in advance.
Jan 28 '07 #1
3 3579
willakawill
1,646 1GB

There are three errors with this code:

mysql_com.h( 184, 15 ) : Type name expected
mysql_com.h( 184, 15 ) : Declaration missing ;
mysql_com.h( 354, 26 ) : 'SOCKET' cannot start a parameter declaration

Could anyone help me?
Thanks in advance.
Hi. The file with the errors, mysql_com.h would not normally contain a main function. Is this the file that you have posted above?
Jan 28 '07 #2
arrow
2
Hi. The file with the errors, mysql_com.h would not normally contain a main function. Is this the file that you have posted above?
No. The code I wrote is not the header file. "mysql_com.h" is called in "mysql.h" automatically.
This problem was solved by including "winsock2.h" header file. Now there are no compile time errors. However there are three linking time errors with MySQL api::

Error: Unresolved external 'mysql_init' referenced from C:\BC5\BIN\MYSQLAPI.OBJ
Error: Unresolved external 'mysql_real_connect' referenced from C:\BC5\BIN\MYSQLAPI.OBJ
Error: Unresolved external 'mysql_close' referenced from C:\BC5\BIN\MYSQLAPI.OBJ

I will try to connect by using the Borland's ODBC functions, not with MySQL api. But I wonder how to solve these linking errors.

Thank you for your interest.

Onur
Jan 30 '07 #3
No. The code I wrote is not the header file. "mysql_com.h" is called in "mysql.h" automatically.
This problem was solved by including "winsock2.h" header file. Now there are no compile time errors. However there are three linking time errors with MySQL api::

Error: Unresolved external 'mysql_init' referenced from C:\BC5\BIN\MYSQLAPI.OBJ
Error: Unresolved external 'mysql_real_connect' referenced from C:\BC5\BIN\MYSQLAPI.OBJ
Error: Unresolved external 'mysql_close' referenced from C:\BC5\BIN\MYSQLAPI.OBJ

I will try to connect by using the Borland's ODBC functions, not with MySQL api. But I wonder how to solve these linking errors.

Thank you for your interest.

Onur
Add libmysql.lib to your project after converting from MS format to Borland format with the command
implib libmysql.lib libmysql.dll
Jul 29 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by sridhar nagabhurshana | last post: by
reply views Thread by Mike Chirico | last post: by
11 posts views Thread by DJJ | last post: by
reply views Thread by guiromero | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.