ct_connect returns failure

"developer loke" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
Hi. This is my first post. I am a novice in freetds programming, and am
trying to connect to a Microsoft Server 2008. I am able to connect with
tsql -Svirtual -Usa -Ddatabase -Ppass. I have set the environment
variable TDSVER=8.0 . I am trying to use the included c code, but the
return at the last line in the following code is 0. What am I doing
wrong?
Loke

code:
int main()
{
CS_CONTEXT *ctx;
CS_CONNECTION *conn;
CS_COMMAND *cmd;
CS_RETCODE ret;
CS_RETCODE restype;
CS_DATAFMT datafmt[10];

   ret = cs_ctx_alloc(CS_VERSION_100, &ctx);
   ret = ct_init(ctx, CS_VERSION_100);
   ret = ct_con_alloc(ctx, &conn);
   ret = ct_con_props(conn, CS_SET, CS_USERNAME, "sa", CS_NULLTERM,
NULL);
   ret = ct_con_props(conn, CS_SET, CS_PASSWORD, "pass", CS_NULLTERM,
NULL);
   /* ret = ct_con_props(conn, CS_SET, CS_IFILE,
"/devl/t3624bb/myinterf", CS_NULLTERM, NULL); */
//always returns zero
   ret = ct_connect(conn, "virtual", CS_NULLTERM);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.