How To Execute Sql Statements From A C Program?
Solution 1:
The old but reliable solution, for *ix as well as Windows, and for all (significant) database servers, is ODBC. I recommend the Easysoft tutorial. According to this, you may have to manually install the SQL Server ODBC driver from CD.
Solution 2:
With C, you'll probably want to use the Microsoft ODBC API: http://msdn.microsoft.com/en-us/library/ms714562(v=VS.85).aspx
I use this heavily in my CSQLBinding class, which contains lots of usage samples. Besides the encapsulating class, (which is obviously C++ only) all of the functionality is completely compatible with plain C.
Solution 3:
There are two main ways to access databases from C programs. The more widely used one is ODBC (sometimes called CLI), as already mentioned by Matthew Flaschen. This is probably the most sensible method to use for SQL Server on Windows. There are other, similar interfaces for other DBMS - notable OCI for Oracle.
The alternative mechanism is called Embedded SQL - exemplified by products such as IBM Informix ESQL/C (a part of IBM Informix ClientSDK). In these systems, there is a precompiler that accepts statements such as:
EXECSQLCREATETABLE x (y INTEGERNOTNULL);
and arranges for the correct interface calls. Clearly, with input and output variables, this saves some effort - the pre-compiler generates the code to handle lists of variables etc that ODBC etc requires you to code explicitly.
Solution 4:
I am now using the following method explained in this question by me.It is satisfying my requirements.
Post a Comment for "How To Execute Sql Statements From A C Program?"