[freetds] Problem connecting to SQL server on linux
Levente Tamási (IJ/ETH)
Levente.Tamasi at ericsson.com
Tue Sep 26 03:19:33 EDT 2006
AFAIK you have to connect first (using, for instance, SQLDriverConnect),
and then you can allocate a statement handle.
From: freetds-bounces at lists.ibiblio.org [mailto:freetds-bounces at lists.ibiblio.org] On Behalf Of Frederik Teerlinck
Sent: Monday, September 25, 2006 6:21 PM
To: freetds at lists.ibiblio.org
Subject: [freetds] Problem connecting to SQL server on linux
I'm trying to connect to an SQL server database using freeTDS on a linux server. I've got an example and I'm trying to use this for my program, but I can't seem to connect to the DB (see code below). The returnvalues from SQLAllocHandle(SQL_HANDLE_STMT, connection, &cmd) and SQLDriverConnect are SQL_ERROR. I'm quit a newbie in this area, so I've got the feeling that I'm missing a step here. Anybody an idea on what's going wrong here? Is there a way I can have get information on why the returncode is an SQL_ERROR?
unsigned char outConnectionString; SQLSMALLINT len;
ret = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &context);
ret = SQLSetEnvAttr (context, SQL_ATTR_ODBC_VERSION, (void*) SQL_OV_ODBC3,
ret = SQLAllocHandle(SQL_HANDLE_DBC, context, &connection);
ret = SQLAllocHandle(SQL_HANDLE_STMT, connection, &cmd); ret = SQLDriverConnect(connection, NULL, (SQLCHAR *) "DRIVER=FreeTDS;Address=<IPaddress of the SQL
outConnectionString, 1024, &len, SQL_DRIVER_NOPROMPT); ....
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
More information about the FreeTDS