mhoang:

I can't really tell. You just don't provide much information to work with.

DSN configuration

Part of the problem is that you're using a DSN to connect, and that hides a lot of information. With just a DSN name, I don't know a thing about your data source configuration. I try to avoid using DSNs and instead spell out the details for each connection, but that's just a personal preference. If you're going to use a DSN to connect to SQL server, though, you need to know a few things. For example, what sort of DSN is it? I'd suggest using a System DSN if you have a choice. If it's a User DSN, then you have to make sure you set up the DSN for the account the web server runs in in exactly the same way as the DSN on your account.

Which ODBC driver does the DSN use? The SQL Native Client might be pretty good, but I've been using the SQL Server driver (v 2000.85.1132.00) for the past few years, and it works well connecting to SQL Server 2005. So just to debug your connection, I'd try using that one. Once you resolve your connection issues, you can then try moving to a different driver, if desired.

I use the DBI module with DBD::ODBC and other modules to access databases, so I have no experience with Win32::ODBC, so if it has any quirks, you'll either have to delve into the documentation, or perhaps someone else might mention them.

Error details

The next part of the problem is that you don't specify the way that it doesn't work. Error messages are sort of handy. Normally they tell you what the problem is. So if you don't tell us the exact text of the error message, we don't know where to start looking for problems. For all we know, you could be using a command line on one computer and the script running on another computer with a different configuration, etc.

...roboticus

In reply to Re^3: Data base connection error by roboticus
in thread Data base connection error by mhoang

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.