[freetds] Unable to connect to data source

Frederik Teerlinck largowww at gmail.com
Thu Sep 28 07:33:46 EDT 2006


I've been looking in that, but that didn't help me. However, it's been
solved although I don't really understand why. If I change in the code below
DSN=MYDBNAME with SERVERNAME=MYDBNAME, then it works. Strange, but ok, at
least it works now.



2006/9/28, Igor Korot <ikorot at earthlink.net>:
>
> Frederick,
> Did you try to search MSDN? This is ODBC problem as a very least...
> >From MSDN:
>
> If the DriverCompletion parameter value is SQL_DRIVER_NOPROMPT or
> SQL_DRIVER_COMPLETE_REQUIRED and the language or database comes from the
> connection string and either is invalid, SQLDriverConnect returns SQL_ERROR.
>
> Reference:
> http://msdn2.microsoft.com/de-de/library/ms131421.aspx
>
> Thank you.
>
> -----Original Message-----
> >From: Frederik Teerlinck <largowww at gmail.com>
> >Sent: Sep 28, 2006 12:17 AM
> >To: freetds at lists.ibiblio.org
> >Subject: [freetds] Unable to connect to data source
> >
> >Well I thought my connection problem was solved, but it isn't. I still
> want
> >to connect from my C++ program on linux to an SQL server database.
> >
> >Here's a part of my code:
> >ret = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &context);
> >ret = SQLSetEnvAttr   (context, SQL_ATTR_ODBC_VERSION, (void*)
> SQL_OV_ODBC3,
> >0);
> >ret = SQLAllocHandle(SQL_HANDLE_DBC, context, &connection);
> >
> >-> this all returns ok
> >
> >ret = SQLDriverConnect(connection, NULL, (SQLCHAR *)
> >"DSN=MYDBNAME;UID=MYUID;PWD=MYPWD", SQL_NTS,
> >outConnectionString, 1024, &len, SQL_DRIVER_NOPROMPT);
> >
> >-> This returns SQL_ERROR. If I get more information with SQLGetDiagRec,
> >this gives me:
> >[FreeTDS][SQL Server]Unable to connect to data source
> >
> >Both:
> >isql MYDBNAME MYUID MYPWD
> >tsql -S MYDBNAME -U MYUID -P MYPWD
> >are working as perfect, so I think my configuration of freetds and the
> odbc
> >driver should be ok.
> >
> >This is my configuration:
> >::::::::::::::
> >odbc.ini
> >::::::::::::::
> >[MYDBNAME]
> >Driver          = TDS
> >Description     = ODBC connection via FreeTDS
> >Trace           = No
> >Servername      = MYDBNAME
> >
> >
> >::::::::::::::
> >odbcinst.ini
> >::::::::::::::
> >[TDS]
> >Description             = FreeTDS
> >Driver          = /usr/lib/odbc/libtdsodbc.so
> >Setup           = /usr/lib/odbc/libtdsS.so
> >FileUsage               = 1
> >
> >
> >In freetds.conf I have:
> >
> >[MYDBNAME]
> >host = my.server.ip.address
> >port = 11433
> >tds version = 8.0
> >
> >
> >I've tried to change the parameters in SQLDriverConnect (adding the port,
> >driver, database, ...), but I always get the same result.
> >
> >Anybody an idea why I can't make a connection?
> >_______________________________________________
> >FreeTDS mailing list
> >FreeTDS at lists.ibiblio.org
> >http://lists.ibiblio.org/mailman/listinfo/freetds
>
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
>



More information about the FreeTDS mailing list