[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freetds
Subject:    Re: [freetds] Connecting to DB using unixODBC from C
From:       "James K. Lowden" <jklowden () freetds ! org>
Date:       2007-04-18 2:36:36
Message-ID: 20070417223636.3a38df11.jklowden () freetds ! org
[Download RAW message or body]

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
_______________________________________________
FreeTDS mailing list
FreeTDS@lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic