[freetds] ct_connect returns failure

developer loke developer.loke at gmail.com
Wed Nov 19 21:42:40 EST 2008


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);



More information about the FreeTDS mailing list