Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to connect to a database using C?

Status
Not open for further replies.

ssudha17

Programmer
Feb 20, 2001
21
US
Hi,
I am making a search engine for generating the possible routes from place A to B, something similar to airline ticketing. So I was thinking of storing the source, destination, starting and arrival times in a database and generating a graph using the same and then determine the ways of reaching from place A to place B using some search algorithm. Hence I need to know how to do a database connection using C. Also if anyone else has worked on something similar,please do let me know.
Regards,
Sudhakar
 
This depends completely on which database you're using. Most databases will provide a C API for you to use to interact with it from a C program.

So, which database are you thinking of using? :)

Russ
bobbitts@hotmail.com
 
Hi,
i wish to use either msaccess or mysql as database. I have to select the database that will allow me ease of date manipulation as I have to indulge in a lot of it (to check the arrival time of flight at each of the connecting place and find out if the connecting flight leaves before or after the arrival, and if later, see to it that its not too long after arrival of the flight). hence I need to select the one that will allow simplicity in doing that. I have done date manipulation using Date::Manip in Unix platform while doing PERL programming but I am not sure how it goes otherwise.Please let me know.
Thanks and regards,
Sudhakar Visit to know more about my achievements
 
just an idea. it might be easier to program this in
perl. as you pointed out, perl has good date manipulation
already, but more specifically, it's well designed for
internet-to-database communication. if you do choose perl,
mysql is the more supported of the two in perl, and would
be the better choice in that situation. you can always ask
in the perl forum for more info on how to set it up...
then again, i can't possibly pretend that i'm being
completely objective in this suggesion. "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
MySQL has an easy to use C API. As stillflame pointed out, Perl would be a good choice with MySQL as well and since you would be using DBI, your code would be easier to port to another database if necessary in the future.

MySQL has some nice features that ease date. You'll probably be able to do most of this through embedded SQL statements, so the language choice probably won't be a factor here.

Whichever language you choose, if you decide on MySQL, there is an excellent book that explains both the C and Perl way of doing things with the database:

MySQL - by Paul Dubois

Sorry, don't know about MS Access.

Russ
bobbitts@hotmail.com
 
i would like to have the code for connecting to either oracle or Mysql database using c++ code. please mail me immediately.
 
Hello Friends,

I am running c on a linux system and want to connect MySQL database. As mentioned by rebobitt, MYSQL has a C API. Where can i find it on my system. Which .h file to include in my programs to use this api. Can i find some help in the form of tutorials on the net. If anybody knows, Pls help me.


Thanks in advance.

sanjeev Gupta
 
Thanks rbobbitt,

But the problem remains same. The documentation on MYSQL.COM suggests that C API for MYSQL is distributed with MYSQL installation file. There is a seprate API named MYSQL++ for c++ but no seprate API for c on also, i did not find "mysql.h" header file on my system to inclued it in my c programs. If there is seprate library for c on MYSQL.COM then plssss give me complete URL.

Pls help.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top