freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "Bartosz Bubak" <bartekb AT teleaudio.com.pl>
- To: <freetds AT franklin.oit.unc.edu>
- Subject: Newbie problem
- Date: Mon, 23 Sep 2002 12:15:15 +0200
Hello
I need simple application working with MSSQL Server 2000, but my application
dont work correctly.
After connection, submit query, tds_process_row_tokens ALWAYS return
TDS_NO_MORE_ROWS (-2) ???
Why ?
My code is from tsql source (tsql with the same query and parameters work
OK) and i dont know what is wrong.
If you have any idea please help.
I use:
SCO UNIX 5.0.5
FreeTds-0.60
MsSQL Server 2000
P.S. I know my english is terribile :)
Sample code:
<code>
int get_pin()
{
int i, rc, n_col;
TDSCOLINFO *col;
int ctype;
CONV_RESULT dres;
unsigned char *src;
TDS_INT srclen;
TDS_INT len;
char *buf;
TDSSOCKET *tds;
TDSLOGIN *login;
TDSCONTEXT *context;
login = (void *) tds_alloc_login();
context = tds_alloc_context();
if( context->locale && !context->locale->date_fmt )
{
/* set default in case there's no locale file */
context->locale->date_fmt = strdup("%b %e %Y %l:%M%p");
}
context->msg_handler = tsql_handle_message;
context->err_handler = tsql_handle_message;
tds_set_user(login, "sss");
tds_set_app(login, "GET_PIN");
tds_set_host(login, "sbs");
tds_set_library(login, "TDS-Library");
tds_set_server(login, "sbs");
tds_set_port(login, 1433);
tds_set_charset(login, "iso_1");
tds_set_language(login, "us_english");
tds_set_packet(login, 512);
tds_set_passwd(login, "sss");
tds = tds_connect(login, context, NULL);
if (!tds)
{
/* FIX ME -- need to hook up message/error handlers */
fprintf(stderr, "There was a problem connecting to the
server\n");
exit(1);
}
rc = tds_submit_query(tds,"select * from piny");
if (rc != TDS_SUCCEED)
{
fprintf(stderr, "tds_submit_query() failed\n");
exit(1);
}
rc = tds_process_row_tokens(tds);
if (rc = TDS_NO_MORE_ROWS)
{
printf("No Data\n");
exit(1);
}
else
if (rc != TDS_SUCCEED)
{
printf("Error (%d)\n",rc);
exit(1);
}
else
{
printf("OK\n");
}
n_col = tds->res_info->num_cols;
printf("Return %d columns\n",n_col);
tds_free_socket(tds);
tds_free_login(login);
tds_free_context(context);
return n_col;
}
</code>
-
Newbie problem,
Bartosz Bubak, 09/23/2002
- <Possible follow-up(s)>
- RE: Newbie problem, ZIGLIO Frediano, 09/23/2002
- RE: Newbie problem, Lowden, James K, 09/23/2002
Archive powered by MHonArc 2.6.24.