Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

inserting images in ms sql server

by ahmedmc (Initiate)
on Jun 19, 2012 at 15:22 UTC ( #977097=perlquestion: print w/ replies, xml ) Need Help??
ahmedmc has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to insert an image into ms sql server but I'm getting some errors while inserting it in db.

"DBD::ODBC::st execute failed: unixODBCFreeTDSSQL ServerError converting client characters into server's character set. Some character(s) could not be converted. (SQL-HY000)"

For inserting image in mysql I was able to insert it i.e. using '?' in insert statement but tried out different methods including N character to insert in ms sql but attempt was unsuccessful. Please advise at earliest to overcome this issue. Stating my query below;

my $dbh = DBI-> connect("dbi:ODBC:DSN=MSSQL;Server=$server_name;Databa +se=$db_name;UID=$db_user;PWD=$db_pass") or die "CONNECT ERROR! :: $DB +I::err $DBI::errstr $DBI::state $!\n"; my $myfile = "/home/sysadm/perl-scripts/fax-5-rx.tif"; open MYFILE, $myfile or die "Cannot open file"; my $data; # Read in the contents while (<MYFILE>) { $data .= $_; } close MYFILE; my $sql = "INSERT into tblImages(imageid,channel,pages,msgid,content) +values ('000111222','8','1','000111222',?)"; my $sth = $dbh->prepare($sql) or die("\n\nPREPARE ERROR:\n\n$DBI::err +str"); $sth->execute($data) or die("\n\nQUERY ERROR:\n\n$DBI::errstr"); $sth->finish; $dbh->disconnect;

Comment on inserting images in ms sql server
Download Code
Re: inserting images in ms sql server
by mje (Deacon) on Jun 20, 2012 at 10:30 UTC

    What is the type of the column "content" in the table?

Re: inserting images in ms sql server
by ksublondie (Pilgrim) on Sep 18, 2012 at 17:51 UTC
    Did you ever find a solution?

    I'm having the same problem with DBD::Sybase using the FreeTDS driver. In my research, I've found that it's an issue with FreeTDS, but I haven't been able to find a specific driver that definitively works yet.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2014-09-18 21:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (125 votes), past polls