Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need Help for connecting MSSQL SERVER From Linux(ubuntu)

I just installed the ODBC driver in the Ubuntu, but still I am facing issues while connecting the database from Perl. Here is the description on what I have done in my machine.

I installed the MSSQL Driver and Unix ODBC from easysoft website. The path details in my machine follows:

ODBC Installed Path:- user/local/easysoft/unixodbc

Data Source and Driver path: user/local/etc Sample Code:

#!/usr/bin/perl  
use strict;  
use DBI;   
my $dsn="DBI:ODBC:DRIVER={SQL Server};Server=xxx.xxx.xxx.xxx,1433;database=DB_name";  
my $dbh = DBI->connect($dsn, "username", "password" ,{AutoCommit => 1} )
            or die DBI::errstr;

Error:

DBI connect('DRIVER={SQL Server};Server=xxx.xxx.xxx.xxx,1433;database=DB_name','username',...) failed: unixODBCDriver Manager Can't open lib 'SQL Server' : file not found (SQL-01000) at sample.pl line 5 
unixODBCDriver ManagerCan't open lib 'SQL Server' : file not found (SQL-01000) at sample.pl line 5.
like image 901
raj Avatar asked Dec 27 '25 16:12

raj


1 Answers

DRIVER={SQL Server}

You code is attepmting to connect to a [SQL Server] driver in your odbcinst.ini file. However if you are using the Easysoft ODBC-SQL Server Driver you will need to use :-

Driver={Easysoft ODBC-SQL Server}
like image 158
Richard Spencer Avatar answered Dec 30 '25 06:12

Richard Spencer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!