Description: I installed SQL Server 2012 on my local machine(Windows 7). At first I installed with Windows authentication. After searching on web, I change to SQL Server authentication and set as: In SQL Server Management Studio->object explorer->security->logins->sa->right click property, select SQL Server authen and set password as "!Abcd1234!" for example.
Then I tried that I can connect by SQL Server authentication with sa/password using Management Studio. But using Perl script I failed.
My simple Perl script as below:
use strict;
use warnings;
use dbi;
my $user = "sa";
my $password = "!Abcd1234!";
my $connect = DBI->connect("dbi:ODBC:Driver={SQL Server};Server=127.0.0.1;UID=$user;PWD=$password")or die "Error: $DBI::errstr\n";
I got error
Error: [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. (SQL-08001) [state was 08001 now 01000]
[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). (SQL-01000)
May I get any help or trace method?
Yes, Mitch Wheat, I do enable "sa" account in the status tab. Sorry missing to mention that. I doubt whether my Perl script is correct? I think access locally should have no firewall issues right?
I have connected many a times from perl (running on linux) to the MSSQL server. and while doing so, I would create a DSN manualy on the my Linux box and then write below syntax to connect:
my $dbh = DBI->connect ('dbi:ODBC:odbc-test', 'sqluser_name', 'sqluser_password');
Where, odbc-test
is the name of the DSN
And it always worked.
unfortunately I never done any perl DBI connection from windows.
So,
On your windows box, could you create a DSN manually first and then follow above mentioned syntax to connect to the MSSQL server .
您应该先使用ODBC管理员来测试连接。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.