[unixODBC-support] unixODBC, php, adodb, DSNs and MSSQL

Nick Gorham nick.gorham at easysoft.com
Fri Aug 31 09:10:44 BST 2007

Rob Brandt wrote:

> Newbie looking for help getting ODBC working.
> I have written an application in php that accesses a hosted MSSQL 2000 
> database over the internet.  I did development on a Windows PC and 
> used the http://adodb.sourceforge.net/ package as a wrapper for cross 
> database SQL queries.  Our goal is to eventually loosen MS's grip on 
> us, but we aren't ready to move from MSSQL yet.  On my workstation, 
> everything works great.  On the server, I cannot get a connection.
> Getting this functioning on the Linux server (hosted) has been a 
> chore.  We've resolved firewall issues, and have gotten unixODBC 
> installed along with FreeTDS, isql and php-odbc.  php is version 5.2.3.
> I have written the application using adodb's "dsn-less" approach, 
> where the connection string contains what's usually in the dsn.  As I 
> said, this works great on my PC.  My question is, is the DSN-less 
> approach valid using unixODBC?  I am certainly willing to get one set 
> up for purposes of testing and proving the connection.  I can also 
> change the connection method in my application if that's what needs to 
> be done.  I have tried setting up a DSN on the linux box, but when I try:
> odbcinst -i -s -f tds.datasource.template -l
> (logged in as user not root)

Just edit the files by hand if that helps. The above command is trying 
to create a system DSN, to do that it probably needs to write to 
/etc/odbc.ini hence the permission issue.

> I get:
> odbcinst: SQLWritePrivateProfileString failed with General error 
> request failed.
> odbcinst: SQLWritePrivateProfileString failed with General error 
> request failed.
> I don't understand the problem; seems like a permission error but no 
> idea how to resolve it, and don't even know that I need a DSN.

You don't, in theory a DSN less connection should be fine, the driver 
manager is happy, you need to have the entry in your /etc/odbcinst.ini 
entry match the driver name you give.

For example, using our (Easysoft's) driver as a example.

in odbcinst.ini:

[Easysoft ODBC-SQL Server]
Driver     = /usr/local/easysoft/sqlserver/lib/libessqlsrv.so
Setup       = /usr/local/easysoft/sqlserver/lib/libessqlsrvS.so
FileUsage       = 1
UsageCount      = 1

Then in the connection string use

$dsn = "Driver={Easysoft ODBC-SQL 

That will get passed to the driver. You will need to consult the driver 
docs as to what parameters you will need in the connection string, as 
once the Driver= entry is resolved, unixODBC passes control over to the 

Nick Gorham
Easysoft Limited
http://www.easysoft.com, http://www.unixODBC.org

More information about the unixODBC-support mailing list