in reply to Re^3: Database connection issue
in thread Database connection issue

Apologies for the delay, but I was too busy yesterday to respond. I can gleefully admit that the code you provided definitely got me a bit further along, but the error message ever remains the same. The only difference this time is that the "Or die" message included is showing up, but maybe not how I think it should? If that's even a thing.

my $dsn = "dbi:ODBC:Driver={SqlServer};SERVER=CND4290H26;Database=Gam +eInfo; Trusted_Connection=Yes;"; my $dbh = DBI->connect($dsn) or die "Couldn't connect.";

As you can see I did modify the code thanks to your inclusion, but the error message is remaining the same. The only inclusion to that, since I ran in debug mode, is: "Uncaught exception from user code: Couldn't connect. at script.pl line 12." That is the connect or die dbh that attempts to call the dsn to connect. The error has to be somewhere in the dsn. Since I'm trying to call it locally, could the error be in the server? Or is it perhaps still an issue with the driver? I apologize for not really getting it, I'm a newcomer with perl.

Replies are listed 'Best First'.
Re^5: Database connection issue
by Corion (Patriarch) on Nov 16, 2015 at 14:11 UTC

    To get more information from DBI, use the ->connect call as it is documented in DBI:

    $dbh = DBI->connect($data_source, $username, $password) or die $DBI::errstr;

    This should output a bit more information.

      Thanks again, it definitely narrowed the issue down some more. The primary issue now is the following error: "Login failed for user 'myinfo' <SQL-28000> at script.pl line 12." "myinfo" in this case is the login name, including my school, for me to get on my laptop.

      my $data_source = "dbi:ODBC:AJsql"; my $username = ""; my $password = ""; my $dsn = "dbi:ODBC:Driver={SqlServer};SERVER=CND4290H26;Database=Game +Info; Trusted_Connection=Yes;"; my $dbh = DBI->connect($data_source, $username, $password) or die $DBI::errstr;

      I added a bit more and went with the source code. Thing is, I don't have a username or password that are required to access the database. I just open the program and I'm in. Is it instead referring to putting the username and password needed to log onto my computer?

      In the spirit of being thorough, I did attempt to put those details into the code (not putting them here for obvious reasons), but the error message is still the Login one.

        This means that Perl is now talking to your database. I would now contact the system or database administrator and ask them how to authenticate to the database server. It seems that "integrated login" should work, but you seem to already supply the Trusted_Connection driver parameter. Maybe adding the domain name to your username or leaving it off changes things. Again, the database administrator should be able to look into the logfiles to tell you why your login attempt fails.