tags:

views:

174

answers:

3

Hello, I want to program against various databases in C. I want to know if all of the major database providers, Oracle, DB2, Sql Server, MySql have an api to use for C. If they all do can you give me some links to what the are but more specifically, how to work with the api?

thanks

+6  A: 

The industry standard for database connectivity is ODBC, which is a C API. This Wikipedia link provides a brief overview and lots of links to other resources.

anon
A: 

This is not really an answer to your question (Neil's answer is the best you're going to get) but it needs saying: C is a very bad choice of language to base this kind of work on these days. You're going to have a miserable experience doing something that would be a breeze in any modern "managed runtime" language.

Daniel Earwicker
Yes, but it's more just to see how it was done before. I know how to do it in java and C#
jumbojs
The posts here insisting C is the wrong choice for $TYPE_OF_PROGRAMMING are rather tiresome. If you don't care about C, don't comment on C questions. I think you'd be very hard-pressed to find a managed runtime calling most databases without C somewhere along the way.
Matthew Flaschen
@Matthew - I speak from long and entirely negative experience, including using ODBC, OLEDB, ADO and Oracle's native OCI client all from C/C++. Given that C is DEFINITELY the wrong choice for many problems, and this is often news to people who are just starting out, if someone asks about access databases from C, and doesn't specify "This is for educational purposes" or "I'm just masochistic", then I will always tell them that there is a better way, because I may be doing them an enormous favour, which is the whole point of this site...
Daniel Earwicker
... so I'm not going to watch other people repeat old mistakes. I'm going to say what needs to be said, for the benefit of those who might otherwise waste huge amounts of time and effort learning about technologies that make as much sense today as trying to use two tin cans and some string for business communication because you never heard about cellphones. Apologies if this irritates you, but the point of this site is to help other people, not reinforce their favourite irrational beliefs.
Daniel Earwicker
Well, I've been using ODBC with C++ for about 15 years and find it very easy to use. But I don't believe that an SO comment is the place to launch a defense of ODBC (or a critique, come to that).
anon
I appreciate the response but honestly my question wasn't "Is C the best choice for what I want to do?" I do find it frustrating that I ask a question about one language and have a bunch of responses telling me to use a different and in their view "better" language. If people have to struggle through C, then they'll learn but just stick to the questions please.
jumbojs
Here you have three answers, only one of which (mine) advises you to consider using a different language, not "a bunch" of responses. It would be absolutely irresponsible if no one had pointed this out, for the benefit of other people who stumble on this question in the future; only idiots would purely stick to literal, narrow answers to questions when there are broader implications around them, and it would make the site far less helpful. My answer, in today's world, is a crucial part of the broader answer to your question and its implications.
Daniel Earwicker
A: 

You can use ODBC. But thats not a good idea, cause of the performance impact it may have on your application.

The answer to your question is yes. All major databases provide some api of their own for you to communicate directly with your database.

The only problem with your question is that you forgot to tell which operating system you will be developing for. The only api i remember right now for those majors databases is libpq (for PostgreSQL). Usually in the developer's website its possible to find apis for languages like C and C++.

Victor
ODBC has no particular performance problems and is in fact the native API for several databases.
anon
"The question to your answer is yes."? :-)
Dunya Degirmenci
Ok, but odbc adds extra functionality to database communication and may be slower than other alternatives.There are other disadvantages of odbc anyway. Usually, native specific apis do a better job.
Victor
ahhaahah, true "The question to your answer is yes." ahahahah lol
Victor