Skip to Content.
Sympa Menu

freetds - C program Select problem

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Rodolphe Ode" <Rodolphe.Ode AT eolas.fr>
  • To: freetds AT franklin.oit.unc.edu
  • Subject: C program Select problem
  • Date: Fri, 1 Jun 2001 10:26:34 +0200


Hi all, I got a problem with a C program that does a SELECT to an SQLServer
via FreeTDS. Actually, this program when compiled on a sun works great. The
problem appears when I compile it on and for an Intel/Linux machine (same
compilation options than on the SUN). I know freeTDS is well installed on
this machine because the connection to the same SQLServer via PHP works
fine. I now (in the C program) the connection is made up correctly since I
can catch a connection error if I set the wrong password. Is there anyone
who knows if my program below is not well built, or if anyone had the same
problem?

thanks a lot for your help!


Rodolphe

PS : the simple purpose of this program is to get the field "cle" from the
table clesMarchands(codeSiret, cle) knowing "codeSiret"

***************************************************************************
***************************************************************************
*************************************

rc = try_tds_login(&login, &tds, __FILE__, verbose);
if (rc != TDS_SUCCEED) {
fprintf(stderr, "try_tds_login() failed\n");
return ("1");
}

sprintf(req,"select cle from clesMarchands where
codesiret='%s'",codeSiret);

rc = tds_submit_query(tds,req);
if (rc != TDS_SUCCEED) {
fprintf(stderr, "tds_submit_query() failed\n");
return ("1");
}

while ((rc=tds_process_result_tokens(tds))==TDS_SUCCEED) {
while ((rc=tds_process_row_tokens(tds))==TDS_SUCCEED) {
strcpy(cle,value_as_string(tds, 0));
}
if (rc == TDS_FAIL) fprintf(stderr, "tds_process_row_tokens()
returned TDS_FAIL\n");
else if (rc != TDS_NO_MORE_ROWS) fprintf(stderr,
"tds_process_row_tokens() unexpected return\n");
}


if (rc == TDS_FAIL) {
fprintf(stderr, "tds_process_result_tokens() returned TDS_FAIL\n");
}
else if (rc != TDS_NO_MORE_RESULTS) {
fprintf(stderr, "tds_process_result_tokens() unexpected return\n");
}

try_tds_logout(login, tds, verbose);

return (strdup(cle));






Archive powered by MHonArc 2.6.24.

Top of Page