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

Stefan Radman Stefan.Radman at CTBTO.ORG
Fri Aug 31 12:03:04 BST 2007


For FreeTDS with MSSQL 2000 you'll probably need

$dsn="Driver={FreeTDS};
      Server=mssql2000.example.com;
      Port=1433;
      TDS_Version=8.0;
      Database=ourdbname;"

Before testing with your own application I'd put everything into a
private DSN ($HOME/.odbc.ini) and test it using isql.
  odbcinst -i -s -f tds.datasource.template # don't use the -l flag
Once that works you can safely assume that the same config will (should)
work as a connection string in your application.

Stefan
> -----Original Message-----
> From: unixodbc-support-bounces at easysoft.com 
> [mailto:unixodbc-support-bounces at easysoft.com] On Behalf Of 
> Nick Gorham
> Sent: Friday, 31 August, 2007 10:11
> To: Support for the unixODBC project
> Subject: Re: [unixODBC-support] unixODBC, php, adodb, DSNs and MSSQL
> 
> 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 
> Server};Server=xxx.xxx.xxx.xxx;Database=ourdbname;";
> 
> 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 
> driver.
> 
> -- 
> Nick Gorham
> Easysoft Limited
> http://www.easysoft.com, http://www.unixODBC.org
> 
> _______________________________________________
> unixODBC-support mailing list
> unixODBC-support at easysoft.com
> http://mail.easysoft.com/mailman/listinfo/unixodbc-support
> 



More information about the unixODBC-support mailing list