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();

In reply to Perl DBI -- SQL Server Error by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.