From: dba.9999 on
I need to connect to sql server from strawberry perl. Is anyone aware of
any free driver for this.

thanks.

From: Erland Sommarskog on
(dba.9999(a)gmail.com) writes:
> I need to connect to sql server from strawberry perl. Is anyone aware of
> any free driver for this.

The best API to connect to SQL Server from Perl is Win32::SqlServer,
http://www.sommarskog.se/mssqlperl/index.html. But keep in mind that
it's designed for SQL Server only, and should not use it you need to
be portable.

I will have to throw in the disclaimer that I don't know if it runs
with Strawberry Perl. Someone mailed me as he he tried to build it on
Strawberry Perl, and had some problems. When I researched it, I found
that Strawberry Perl assumes DMAKE and GNU-CC. I've only built
Win32::SqlServer with Visual C++, and playing with GNU-CC is not really
in my realm. The other person ended up using ActivePerl instead.

There is a binary distribution, which you can try, but I would expect it
to be compatible with something built with a different compiler.

Other Perl alternatives are Win32::ODBC and the DBD::ADO, and I think
there is a DBD for FreeTDS as well, see
http://www.sommarskog.se/mssqlperl/alternatives.html for what I have
listed there.


--
Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
From: dba.9999 on
In article <Xns9CB2AA23EFA6DYazorman(a)127.0.0.1>, Erland Sommarskog says...


OK I installed Win32::SQLServer

my connection is failing:

use Win32::SqlServer ;
my $server = 'OWNER_PC\SQLEXPRESS' ;
my $user = 'sa' ;
my $pw = '<MYPASSWORD>' ;
my $database = 'master' ;
my $provider = 'SQLNCLI10' ;
$sqlsrv = Win32::SqlServer->sql_init($server, $user, $pw, $database, $provider);


this gives this error

SQL Server message 53, Severity 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [53].
Message 08001 from 'Microsoft SQL Server Native Client 10.0', Severity: 16
A network-related or instance-specific error has occurred while establishing a
connection to SQL Server. Server is not found or not accessible. Check if
instance name is correct and if SQL Server is configured to allow remote
connections. For more information see SQL Server Books Online.
Message HYT00 from 'Microsoft SQL Server Native Client 10.0', Severity: 16
Login timeout expired
Terminating on fatal error at test.pl line 7

The error is same when I change $provider to SQLOLEDB

thanks a lot.

From: Erland Sommarskog on
(dba.9999(a)gmail.com) writes:
> In article <Xns9CB2AA23EFA6DYazorman(a)127.0.0.1>, Erland Sommarskog says...
>
>
> OK I installed Win32::SQLServer
>
> my connection is failing:
>
> use Win32::SqlServer ;
> my $server = 'OWNER_PC\SQLEXPRESS' ;
> my $user = 'sa' ;
> my $pw = '<MYPASSWORD>' ;
> my $database = 'master' ;
> my $provider = 'SQLNCLI10' ;
> $sqlsrv = Win32::SqlServer->sql_init($server, $user, $pw, $database,
> $provider);
>
>
> this gives this error
>
> SQL Server message 53, Severity 16, State 1
> Named Pipes Provider: Could not open a connection to SQL Server [53].
> Message 08001 from 'Microsoft SQL Server Native Client 10.0', Severity: 16
>...

That's a generic connection error meaning that you were not able to find
the SQL Server instance at all. I would expect that you would get the
same error message if you tried

sqlcmd -S OWNER_PC\SQLEXPRESS -U sa -P password

from a command-line window.


Is SQL Server running at all?
Is it running on the same machine as the Perl script?
If it runs on a different machine, make sure that remote connections are
enabled; by default it it is not for SQL Express. Also make sure that
the SQL Browser service is running and that there are no firewalls in the
way.



--
Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
From: dba.9999 on
In article <Xns9CB36285BA9DFYazorman(a)127.0.0.1>, Erland Sommarskog says...

>That's a generic connection error meaning that you were not able to find
>the SQL Server instance at all. I would expect that you would get the
>same error message if you tried
>
> sqlcmd -S OWNER_PC\SQLEXPRESS -U sa -P password

No, sqlcmd works fine.

>Is SQL Server running at all?

yes, otherwise sqlcmd would also report error.

>Is it running on the same machine as the Perl script?

yes, both on my laptop.