Skip to Content.
Sympa Menu

freetds - Re: [freetds] Connection problem from php : Unable to connect to data source, SQL state S1000 in SQLConnect

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddy77 AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Connection problem from php : Unable to connect to data source, SQL state S1000 in SQLConnect
  • Date: Tue, 9 Oct 2012 18:19:50 +0100

2012/10/3 Marc-André Legrand <legrandmarc20 AT hotmail.com>:
>
>
>
> Hello everybody,
>
> I have difficult to connect from php to MS SQL Server. I have the following
> message in php page :
>
> [unixODBC][FreeTDS][SQL Server]Unable to connect to data source, SQL state
> S1000 in SQLConnect
>
>
> I made an installation Freetds via yum install . I configured freedts.conf
> in /etc/ folder .
>
> Here is the code in /etc/freetds.conf
>
> # $Id: freetds.conf,v 1.12 2007/12/25 06:02:36 jklowden Exp $
> #
> # This file is installed by FreeTDS if no file by the same
> # name is found in the installation directory.
> #
> # For information about the layout of this file and its settings,
> # see the freetds.conf manpage "man freetds.conf".
> # Global settings are overridden by those in a database
> # server specific section
> [global]
> # TDS protocol version
> ; tds version = 4.2
> # Whether to write a TDSDUMP file for diagnostic purposes
> # (setting this to /tmp is insecure on a multi-user system)
> ; dump file = /tmp/freetds.log
> ; debug flags = 0xffff
> # Command and connection timeouts
> ; timeout = 10
> ; connect timeout = 10
> # If you get out-of-memory errors, it may mean that your client
> # is trying to allocate a huge buffer for a TEXT field.
> # Try setting 'text size' to a more reasonable limit
> text size = 64512
> # A typical Sybase server
> ;[egServer50]
> ; host = symachine.domain.com
> ; port = 5000
> ; tds version = 5.0
> # A typical Microsoft server
> ;[egServer70]
> ; host = ntmachine.domain.com
> ; port = 1433
> ; tds version = 7.0
> [TDS]
> host = <My IP Address>
> port = 1433
> tds version = 8.0
>
>
> Here is my /etc/odbcinst.ini file :
>
> [PostgreSQL]
> Description = ODBC for PostgreSQL
> Driver = /usr/lib/psqlodbc.so
> Setup = /usr/lib/libodbcpsqlS.so
> Driver64 = /usr/lib64/psqlodbc.so
> Setup64 = /usr/lib64/libodbcpsqlS.so
> FileUsage = 1
>
> [MySQL]
> Description = ODBC for MySQL
> Driver = /usr/lib/libmyodbc5.so
> Setup = /usr/lib/libodbcmyS.so
> Driver64 = /usr/lib64/libmyodbc5.so
> Setup64 = /usr/lib64/libodbcmyS.so
> FileUsage = 1
>
> [FreeTDS]
> Description = v0.64 with protocol v8.0
> Driver = /usr/lib64/libtdsodbc.so.0
> ForceTrace = Yes
> Trace = Yes
> TraceFile = /tmp/sql.log
> UsageCount = 1
>
> And this my php code to connect to SQL Server :
>
> $connexion_mssql_reussie = true;
>
> $dsn="Driver=FreeTDS;Server=<My IP Address>;Database=<My
> database>;UID=<User name>;Pwd=<My password>";
> if(($conn=odbc_connect($dsn,'','')) == TRUE){

Hi,
if you are using Server in connection string FreeTDS does not read
freetds.conf file! My suggestion is usually to follow these steps:
- get tsql working. This will confirm that your parameters (server,
port/instance, tds version) are fine;
- get isql working. This will confirm that odbc is working. There is a
osql script that help you spot odbc problems;
- get your odbc application working using Servername;
- optionally convert connection string to avoid using freetds.conf
(DSN-less connection, see UserGuide for details).

> $connexion_mssql_reussie = true;
> }else{
> die("Erreur de connexion");
>
> }
>
>
> I use a CentOS web server and SQL Server 2008 with Windows 2008 server .
>
> I would like to know if I forgot something .
>
> Thank you for your reply .
>
> Best regards.
>

Regards,
Frediano




Archive powered by MHonArc 2.6.24.

Top of Page