Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

MCDE and DBD::ODBC issues

by peschkaj (Pilgrim)
on Nov 07, 2002 at 18:33 UTC ( #211174=perlquestion: print w/ replies, xml ) Need Help??
peschkaj has asked for the wisdom of the Perl Monks concerning the following question:

I'm running MCDE on winXP AS Perl. When I attempt to connect to the database with DBD::ODBC I get the following error: Unable to connect: MicrosoftODBC Driver Manager Invalid string or buffer length (SQL-S1090)(DBD: db_login/SQLConnect err=-1)

here is my code:

use DBI; use CGI; use CGI::Carp qw( fatalsToBrowser ); my $q = new CGI; print $q->header( -type=>"text/html", -charset=>"UTF-8" ), $q->start_html( -title => "myCrap.arg" ), $q->p("This is my thing!"); my ( $data_source, $database, $port, $user_id, $password ) = qw( "PIKA +CHU\NetSDK", "HarvestDay", "127.0.0.1:2433", "HarvestReader", "reader +" ); my $conn_string = "driver={SQL Server}; Server=$data_source; tcpip=$po +rt; Database=$database; UID=$user_id; PWD=$password;"; my $dbh = DBI->connect("dbi:ODBC:$conn_string") or die "Unable to conn +ect: $DBI::errstr\n"; my $sth = $dbh->prepare("SELECT * from harvest") or die "Unable to pre +pare: $DBI::errstr\n"; $sth->execute; while ( my @row = $sth->fetchrow_array ) { foreach my $item ( @row ) { $q->p("$item || "); } } print $q->end_html;

I looked through earlier nodes, but none of the solutions provided seemed to help.

Thanks for your assistance

If you make something idiot-proof, eventually someone will make a better idiot.
I am that better idiot.

Comment on MCDE and DBD::ODBC issues
Download Code
Re: MCDE and DBD::ODBC issues
by wardk (Deacon) on Nov 07, 2002 at 21:46 UTC
    my ( $data_source, $database, $port, $user_id, $password ) = qw( "PIKA +CHU\NetSDK", "HarvestDay", "127.0.0.1:2433", "HarvestReader", "reader +" );
    doesn't produce what you are expecting...

    print them out, you'll see embedded quotes and with some, a comma.

    like $database, it equals:

    "HarvestDay",
    this would likely explain "invalid string" good luck!
      Thank you for pointing out my slip-up in such a polite way. ++ to you my friend.

      If you make something idiot-proof, eventually someone will make a better idiot.
      I am that better idiot.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://211174]
Approved by mr2
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2015-07-06 04:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls