Connecting to SQL Server through ODBC using Perl 
Author Message
 Connecting to SQL Server through ODBC using Perl

I am having a problem connecting to SQL Server. I have been using perl to
connect through ODBC to an MS Access database and everything was working
fine. Now I am plugging in a new ODBC connection to a SQL Server and I get
an error. I am hoping I am just making a syntax error.

The error I receive is:

Can't call method "Sql" on an undefined value at
c:\inetpub\wwwroot\ivm\test.pl line 10.

The code I am using is:

#!/usr/local/bin/perl

use Win32::ODBC;

$dsn = "SQL_IMS_LOCAL";

$sql = "SELECT * FROM profiles WHERE emp_number=8908;";

$db = new Win32::ODBC($dsn);

$db->Sql($sql);

($ErrNum, $ErrText, $ErrConn) = $db->Error();

if ($ErrNum) {

&printErrorHeader;

Quote:
}

print <<ENDTEST;

Content type: text/html\n\n

<html>

<head><title>Test</title>

</head>

<body>

<table>

<tr>

<td>

ENDTEST

$db->FetchRow();

( $emp_number, $name, $password, $mas_loc, $email ) = $db->Data(
"emp_number", "name", "password", "mas_loc", "email" );

print "$emp_number, $name, $password, $mas_loc, $email<br>";

$db->Close();

print <<ENDTEST;

<br><br>test

</td>

</tr>

</table>

</body>

</html>

ENDTEST

  --------== Posted Anonymously via Newsfeeds.Com ==-------
     Featuring the worlds only Anonymous Usenet Server
    -----------== http://www.*-*-*.com/ ==----------



Sun, 26 Oct 2003 00:22:37 GMT  
 Connecting to SQL Server through ODBC using Perl
I am having a problem connecting to SQL Server. I have been using perl to
connect through ODBC to an MS Access database and everything was working
fine. Now I am plugging in a new ODBC connection to a SQL Server and I get
an error. I am hoping I am just making a syntax error.

The error I receive is:

Can't call method "Sql" on an undefined value at
c:\inetpub\wwwroot\ivm\test.pl line 10.

The code I am using is:

#!/usr/local/bin/perl

use Win32::ODBC;

$dsn = "SQL_IMS_LOCAL";

$sql = "SELECT * FROM profiles WHERE emp_number=8908;";

$db = new Win32::ODBC($dsn);

$db->Sql($sql);

($ErrNum, $ErrText, $ErrConn) = $db->Error();

if ($ErrNum) {

&printErrorHeader;

Quote:
}

print <<ENDTEST;

Content type: text/html\n\n

<html>

<head><title>Test</title>

</head>

<body>

<table>

<tr>

<td>

ENDTEST

$db->FetchRow();

( $emp_number, $name, $password, $mas_loc, $email ) = $db->Data(
"emp_number", "name", "password", "mas_loc", "email" );

print "$emp_number, $name, $password, $mas_loc, $email<br>";

$db->Close();

print <<ENDTEST;

<br><br>test

</td>

</tr>

</table>

</body>

</html>

ENDTEST

  --------== Posted Anonymously via Newsfeeds.Com ==-------
     Featuring the worlds only Anonymous Usenet Server
    -----------== http://www.newsfeeds.com ==----------



Sun, 26 Oct 2003 00:42:13 GMT  
 Connecting to SQL Server through ODBC using Perl
You should consider using DBI-ODBC. I'm using DBI to connect to SQL Server
without any problems.

-David


Quote:
> I am having a problem connecting to SQL Server. I have been using perl to
> connect through ODBC to an MS Access database and everything was working
> fine. Now I am plugging in a new ODBC connection to a SQL Server and I get
> an error. I am hoping I am just making a syntax error.

> The error I receive is:

> Can't call method "Sql" on an undefined value at
> c:\inetpub\wwwroot\ivm\test.pl line 10.

> The code I am using is:

> #!/usr/local/bin/perl

> use Win32::ODBC;

> $dsn = "SQL_IMS_LOCAL";

> $sql = "SELECT * FROM profiles WHERE emp_number=8908;";

> $db = new Win32::ODBC($dsn);

> $db->Sql($sql);

> ($ErrNum, $ErrText, $ErrConn) = $db->Error();

> if ($ErrNum) {

> &printErrorHeader;

> }

> print <<ENDTEST;

> Content type: text/html\n\n

> <html>

> <head><title>Test</title>

> </head>

> <body>

> <table>

> <tr>

> <td>

> ENDTEST

> $db->FetchRow();

> ( $emp_number, $name, $password, $mas_loc, $email ) = $db->Data(
> "emp_number", "name", "password", "mas_loc", "email" );

> print "$emp_number, $name, $password, $mas_loc, $email<br>";

> $db->Close();

> print <<ENDTEST;

> <br><br>test

> </td>

> </tr>

> </table>

> </body>

> </html>

> ENDTEST

>   --------== Posted Anonymously via Newsfeeds.Com ==-------
>      Featuring the worlds only Anonymous Usenet Server
>     -----------== http://www.newsfeeds.com ==----------



Sun, 26 Oct 2003 22:55:40 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Connecting to SQL Server through ODBC using Perl

2. Using DBI on SunOS to connect to SQL Server

3. LONG: Req: Help in retrieving values from SQL Server stored procedure using Win32::ODBC

4. DBD::ODBC::db prepare failed: [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'tblClient'. (SQL-S0002)

5. Perl 5 on unix to connect to SQL Server 6.5

6. how to use perl to connect SQL Server

7. Perl on NT connect to SQL Server

8. Connecting SQL Server from Perl

9. Q: Can't connect to SQL data source name via Win32::ODBC API

10. Can't Use Win32::ODBC to Connect to MS SQL

11. ODBC perl module to access MS-SQL Server?

12. Perl->odbc->sql server stored proc wierdness

 

 
Powered by phpBB® Forum Software