Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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;

Replies are listed 'Best First'.
Re: inserting images in ms sql server
by mje (Curate) 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 (Friar) 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://977097]
Approved by Corion
[choroba]: the reporter is my colleague, BTW, albeit in a different team

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2018-06-20 12:08 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (116 votes). Check out past polls.