I have a bit of code that uses Win32::ODBC to connect to a Microsoft SQL
database to retrieve some info.  It performs the look-up using data from a
different database that may or may not have special characters in it.

How do I create the sql statement to prevent any erroneous readings of
special characters?

Here is an example of what errors in my code.
**********
         if ($db->Sql("select name from computer where description =
\'".$Title."\'")){
           print "SQL failed.\n";
           print "Error: " . $db->Error() . "\n";
         } else  {
          while($db->FetchRow()){
            undef %Data;
            %Data = $db->DataHash();
            ($computer)=$db->Data("name");
                push(@Computers,$computer);             
          }
**********

If a $Title is submitted that contains several apostrophes there will be a
look-up failure.  I have tried inserting

$Title=~s/'/\\'/g; 

to fix the apostrophes and it did, but the Sql object or the datasource must
require some other massaging?

Can anyone help out here?

Kevin Ailes
Administrator
OTTO Engineering
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to