[freetds] (newbie) Using tsql in C/C++
James K. Lowden
jklowden at schemamania.org
Thu Apr 21 21:59:38 EDT 2005
Ben Borofka <bborofka at gmail.com> wrote:
> I'm writing an app (in Objective-C/Cocoa) that needs to connect to a
> MS SQL 2000 Server. I'm able to compile and run tsql on OS X and it
> works fine. I can connect to the server and issue SQL commands. Now I
> just need to figure out how to put this functionality in my program.
> This is where I'm getting really confused. I need to find some C/C++
> code to do this, and the source code for freetds is really
> overwhelming and complicated. All I need to be able to do is connect
> to the server, exec a few stored procedures and get some output. I'm
> looking for some samples, but the Documentation doesn't explain much
> of using freetds w/ C at all.
I wrote apps/bsqldb.c just for you. You might not need everything it
does, but it's meant to be so that you can pull out what you need.
As Brian said, db-lib is documented online by both vendors. There is also
a reference manual included in the distribution.
For a super-brief introduction:
install error and message handlers
We speak of "results" as the output of a select statement. Because a
query sent with dbcmd may have more than one select statement, we may get
several results. Hence the nested loop.
More information about the FreeTDS