473,394 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 3943
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

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

Similar topics

0
by: Heikki Tuuri | last post by:
Hi! Many people have complained over years that Borland's dbExpress driver does not work with MySQL and transactions, because it disconnects from mysqld after each SQL statement. The postings...
0
by: Simon Hodgson | last post by:
I've been playing with the Borland dbExpress Drivers, and it would appear that Borland only have beta drivers for MySQL 4.x.x However it would also appear to be possible to access a MySQL v 4.x.x...
0
by: sridhar nagabhurshana | last post by:
hello I am trying to connect to mysql database using connector/J jdbc driver this is my code import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException;
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
11
by: DJJ | last post by:
I am using the MySQL ODBC 3.51 driver to link three relatively small MySQL tables to a Microsoft Access 2003 database. I am finding that the data from the MySQL tables takes a hell of a long time...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
7
by: Ike | last post by:
Let's say I have a MySQL 4.12 database, opened to the internet on 111.111.111.111 allowing all incoming and outgoing ports. I have a username and password setup, which CAN connect to this database,...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
39
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.