Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello , Im using SQL Server 2008 which is installed locally in my system . were im trying to connect my database with perl module DBI but while executing the below it throws an error :
DBI connect('Driver={SQL Server};Server=SRINI-PC;Database=ERP','sa',.. +.) failed: [Microsoft][ODBC SQL Server Driver][Shared Memory]SQL Server does not + exist or access denied. (SQL-08001) [state was 08001 now 01000] [Microsoft][ODBC SQL Server Driver][Shared Memory]ConnectionOpen (Conn +ect()). (S QL-01000) at ETLTEST.pl line 10
Kindly help me to fix ,this
use DBI; # DBD::ODBC my $dsn = 'DBI:ODBC:Driver={SQL Server}'; my $host = 'SRINI-PC'; my $database = 'ERP'; my $user = 'sa'; my $auth = 'sri@123'; # Connect via DBD::ODBC by specifying the DSN dynamically. my $dbh = DBI->connect("$dsn;Server=$host;Database=$database", $user, +$auth, { RaiseError => 1, AutoCommit => 1} ) || die "Database connect +ion not made: $DBI::errstr" ; print "testing"; my $sql = "SELECT enqno, enqdate, cuscode FROM tbl_CusEnqry "; my $sth = $dbh->prepare( $sql ); #Execute the statement $sth->execute(); my( $id, $name, $phone_number ); # Bind the results to the local variables $sth->bind_columns( undef, \$id, \$name, \$phone_number ); #Retrieve values from the result set while( $sth->fetch() ) { print "$id, $name, $phone_number\n"; } #Close the connection $sth->finish(); $dbh->disconnect();

Replies are listed 'Best First'.
Re: Perl DBI -- SQL Server Error
by NetWallah (Canon) on Jul 23, 2013 at 13:50 UTC
    In addition to what Anonymonk said:
    my $host = 'SRINI-PC';
    This is just a guess, but that looks like a local PC name, not a SQL server host name.

    If this is the case, please set the SQL server host name there.

                 My goal ... to kill off the slow brain cells that are holding me back from synergizing my knowledge of vertically integrated mobile platforms in local cloud-based content management system datafication.

      "Im using SQL Server 2008 which is installed locally in my system"

      That could be their hostname.

Re: Perl DBI -- SQL Server Error
by poj (Abbot) on Jul 23, 2013 at 14:15 UTC
    If you installed a default instance rather than named instances then try
    my $host = 'SRINI-PC\MSSQLSERVER';
    poj
Re: Perl DBI -- SQL Server Error
by Anonymous Monk on Jul 23, 2013 at 13:29 UTC

    Kindly help me to fix ,this

    Either correct the servername or gain authorization

    This message Server does not exist or access denied. (SQL-08001) means $host is wrong, or $user+$auth is wrong, or $user+$auth has no permission

    Only you (or your admin) can find out which