<html>
<body>
Hello All, especially DBI DBD::ODBC and Win32::ODBC experts,<br><br>
I am writing an application for a client that accesses data in Microsoft
SQLServers.&nbsp; Currently I have parallel developments underway using
both DBD::ODBC and Win32::ODBC on ActiveState Perl, v5.8.3 build
809.&nbsp; The target platforms for the client application are W2K and
XP.&nbsp; The application accesses multiple SQLServers concurrently and
will be installed on many desktop PCs.&nbsp; This makes ease of
installation and admin very important.<br><br>
I can easily create DSN definitions using the ODBC Data Source
Administrator in the Control Panel.&nbsp; My applet based definitions all
work so the problem is not being able to access those servers.&nbsp; I
prefer instead to use the DSN string specification.&nbsp; Using the
applet is very easy for someone installing from the keyboard but a pain
in the petootie for remote installs on Windows.&nbsp; Windows of course,
hides the DSN attributes in multiple keys in the registry.&nbsp; Problem
is, there is a dearth of documentation on specifying the DSN
string.&nbsp; Most writers on DBI discuss the Control Panel applet,
because it is so easy and the string method is relatively
obscure.<br><br>
Cases in point:<br><br>
Here is one way to make a connection to an SQLServer using the external
DSN definition:<br><br>
use DBI;<br>
my $DSN =
'clesql01';<x-tab>&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>#
logical name given to a data source in applet<br>
my $dbh = DBI-&gt;connect(&quot;dbi:ODBC:$DSN&quot;, 'username',
'userpw',<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>{
RaiseError =&gt; 1, AutoCommit =&gt; 1 })<br>
&nbsp;<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>or
die &quot;$DBI::errstr\n&quot;;<br><br>
or,<br><br>
use Win32::ODBC;<br>
my $db = new
Win32::ODBC(&quot;DSN=clesql01;UID=username;PWD=userpw&quot;) or die
Win32::ODBC::Error();<br><br>
Both of these work just fine but what I prefer to write is something
like:<br><br>
use DBI;<br>
my $DSN = 'driver={SQL
Server};Server=node.domain.com;database=my_database;uid=username;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>pwd=userpw;';<br>
my $dbh = DBI-&gt;connect(&quot;dbi:ODBC:$DSN&quot;, 'username',
'userpw',<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>{
RaiseError =&gt; 1, AutoCommit =&gt; 1 })<br>
&nbsp;<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>or
die &quot;$DBI::errstr\n&quot;;<br><br>
or, in Win32::;<br><br>
use Win32::ODBC;<br>
my $DSN = 'driver={SQL
Server};Server=node.domain.com;database=my_database;uid=username;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>pwd=userpw;';<br>
my $db = new Win32::ODBC(&quot;$DSN&quot;) or die
Win32::ODBC::Error();<br><br>
I found the following example in the ActiveState documentation, and is
the basis for those code fragments above.&nbsp; The problem is, it does
not work.&nbsp; I am assuming the example is correct but insufficient,
and is missing mandatory attributes that the MS ODBC driver requires; for
example the server port number and the network protocol.&nbsp; I have
been hacking different key=value pairs trying to guess what the driver
requires, but so far all have failed.&nbsp; The error messages from the
driver are not much help.&nbsp; They state the obvious, client failure to
connect.<br><br>
Does anyone know exactly how to specify a DSN string for SQLServer?&nbsp;
Thanks in advance for at least reading this post, and any help will be
much appreciated.<br><br>
======= From ActiveState Perl documentation ==========<br>
Example (using MSSQL Server):<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $DSN = 'driver={SQL
Server};Server=server_name;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
database=database_name;uid=user;pwd=password;';<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $dbh&nbsp; =
DBI-&gt;connect(&quot;dbi:ODBC:$DSN&quot;) or die
&quot;$DBI::errstr\n&quot;;<br><br>
<br>
<x-sigsep><p></x-sigsep>
Regards,<br>
Will Schmidt<br><br>
<font size=2><b>WilliamSchmidt.com, LLC<br>
</b>11201 NW 77th Street<br>
Terrebonne, OR&nbsp; 97760<br>
541 504-0290<br>
will@williamschmidt.com<br>
<a href="http://www.williamschmidt.com/" eudora="autourl">http://www.williamschmidt.com/</a><br>
</font></body>
</html>