Apart from all the other things people have told you about this script:
- 'DBI:ODBC:' should be 'dbi:ODBC:'
- $connect_string should use uppercase for 'driver' e.g., DRIVER.
- I see you commented out PrintError and RaiseError and I'm guessing you did that because you couldn't work out how to pass them to connect without supplying another username and password as connect is (connect_string, username, password, attributes). You can either a) just set RaiseError/PrintError off the $dbh after connect e.g., $dbh->{PrintError} = 0 or b) take UID=$user;PWD=$password out of your $connect_string and pass them as the 2nd and 3rd args to DBI's connect then put your commented code as the 4th argument.
- You don't need to use DBD::ODBC. DBI loads that for you. The only time you might want to use DBD::ODBC is if you needed some symbols it does not export by default.
- I doubt you want to include host=localhost as I don't believe any SQL Server Server drivers use that connection attribute - but I've not seen them all.
- I'd be surprised if you really had an ODBC driver called "SQL Server" as I've never seen that on unix (and other comments in this thread seemed to suggest you were using unix). The string you assign to DRIVER needs to be a driver located in you odbcinst.ini file - it will be a name between square brackets - see example below.
[Easysoft ODBC-SQL Server]
Driver=/usr/local/easysoft/sqlserver/lib/libessqlsrv.so
Setup=/usr/local/easysoft/sqlserver/lib/libessqlsrvS.so
Threading=0
FileUsage=1
DontDLClose=1
UsageCount=27
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|