[freetds] (newbie) Using tsql in C/C++

Ben Borofka bborofka at gmail.com
Tue Apr 26 00:27:03 EDT 2005


This looks like what I need to use. However, I seem to have trouble  
connecting to the database with your tool. I keep getting an error:

bsqldb.c:170: failed assertion `dbproc != NULL'

And when I comment out that line, I get a bus error. I am launching  
it with the same arguments I launch tsql with:

$ bsqldb -S server -U username -P password

tsql seems to be the only thing I can connect to the server with, but  
a strange thing seems to happen with that. If I try to connect with  
the password as an argument (...-P password...), I cannot connect.  
However, if I try connecting without the argument, then just type the  
password in when it prompts me, it will connect. Anyone know the  
reason for this?

Ben

On Apr 21, 2005, at 6:59 PM, James K. Lowden wrote:

> 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.
>>
>
> Welcome.
>
>
>> 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
> dblogin
> dbconnect
> dbcmd
> dbsqlexec
> while dbresults
>     dbbind col1
>     ...
>     dbbind colN
>     while dbnextrow
>         [process data]
>     wend
> wend
>
> 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.
>
> --jkl
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
>



More information about the FreeTDS mailing list