Problem getting Perl - SQL Server connect working - syntax error?
am 15.08.2006 18:35:34 von Chris.Powers
OK, someone did point out a syntax error (thanks!), but may have found
the glitch...this may sound basic, but I don't know... Do I need to
already have created a DSN file somewhere that this Perl code uses? =20
I've been able to go thru the ODBC applet in MS Server and create user,
system and file DSNs to this same database, all worked. But I can't
connect to the SQL Server thru Perl directly using my code.
So, is this where / what the "Data source name not found and no default
driver specified" are referring to, some other config file that contains
this info? =20
I first thought we built a DSN with the line below so I don't need to
already have a DSN created? But maybe not?
DBI->connect($data_source, $db_user, $db_pass)
Thanks,
Chris=20
=20
=20
=20
LEGAL DISCLAIMER=20
The information transmitted is intended solely for the individual or =
entity to which it is addressed and may contain confidential and/or =
privileged material. Any review, retransmission, dissemination or other =
use of or taking action in reliance upon this information by persons or =
entities other than the intended recipient is prohibited. If you have =
received this email in error please contact the sender and delete the =
material from any computer.=20
=20
Seeing Beyond Money is a service mark of SunTrust Banks, Inc.=20
[ST:XCL]=20
=20
=20
=20
=20
Re: Problem getting Perl - SQL Server connect working - syntax error?
am 15.08.2006 19:01:09 von jseger
My bad for just spotting syntax and not thinking about ODBC. Yes, you
can create a DSN via the control panel->Administrative Tools->Data
Sources (assuming win XP). I've always used System DSN's, rather than
file based, but the syntax for a filebased one is in perldoc
DBD::ODBC.
Actually, reading the perldoc further (hint, hint) I see that you can
create a DSN-less connection, but the syntax amounts to creating a DSN
on the fly.
Once you have created a DSN, the syntax to connect is:
my $DSN = (name or definition here);
$dbh = DBI->connect("dbi:ODBC:$DSN", '','', $attr};
Empty strings are passed for user and password as they are contained in the DSN.
On 8/15/06, Powers.Chris wrote:
> OK, someone did point out a syntax error (thanks!), but may have found
> the glitch...this may sound basic, but I don't know... Do I need to
> already have created a DSN file somewhere that this Perl code uses?
>
> I've been able to go thru the ODBC applet in MS Server and create user,
> system and file DSNs to this same database, all worked. But I can't
> connect to the SQL Server thru Perl directly using my code.
>
> So, is this where / what the "Data source name not found and no default
> driver specified" are referring to, some other config file that contains
> this info?
>
> I first thought we built a DSN with the line below so I don't need to
> already have a DSN created? But maybe not?
> DBI->connect($data_source, $db_user, $db_pass)
>
> Thanks,
>
> Chris
>
>
>
> LEGAL DISCLAIMER
> The information transmitted is intended solely for the individual or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this email in error please contact the sender and delete the material from any computer.
>
> Seeing Beyond Money is a service mark of SunTrust Banks, Inc.
> [ST:XCL]
>
>
>
>
>
--
------------------------------------------------------------ --------------------------------------------------
The darkest places in hell are reserved for those who maintain their
neutrality in times of moral crisis.
Dante Alighieri (1265 - 1321)
They who would give up an essential liberty for temporary security,
deserve neither liberty or security.
Benjamin Franklin
Our lives begin to end the day we become silent about things that matter.
Martin Luther King
The right of the people to be secure in their persons, houses, papers,
and effects, against unreasonable searches and seizures, shall not be
violated, and no warrants shall issue, but upon probable cause,
supported by oath or affirmation, and particularly describing the
place to be searched, and the persons or things to be seized.
Amendment IV to the Constitution of the United States
------------------------------------------------------------ --------------------------------------------------