Skip to Content.
Sympa Menu

freetds - Re: [freetds] Connecting to DB using unixODBC from C

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Connecting to DB using unixODBC from C
  • Date: Tue, 17 Apr 2007 22:36:36 -0400

Rattan, Neeta S wrote:
> As it turns out, I had a problem with an earlier call, the
> SqlAllocHandle() was returning an error that I wasn't catching until I
> started going line by line with the error handling and there was no
> problem with the SqlDriverConnect() line at all.

If I may offer some advice, I have found with this kind of programming
it's especially important to check every function for errors. When I'm
writing new code in a hurry, if I don't want to specify user friendly
error-checking, I use assert(3) so at least my program dies and I know
which line it was on. That's much better than trying to figure out why
the *next* function is failing. ;-)

Even the error handler can have errors, so:

ret = SQLGetDiagField(hType, handle, 0, SQL_DIAG_NUMBER, &ndiag,
sizeof(ndiag), NULL);
assert(ret == SQL_SUCCESS);

Just a friendly suggestion, of course.

Regards,

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page