Re: error for insert into varbinary column: Implicit conversion from data type varchar to varbinary is not allowed

Hari Krishna Dara <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
On Thu, Feb 25, 2010 at 10:20 AM, <[email protected]> wrote:
>
>
> Message: 2
> Date: Wed, 24 Feb 2010 21:24:47 -0500
> From: "James K. Lowden" <[email protected]>
> Subject: Re: [freetds] error for insert into varbinary column:
>        Implicit conversion from data type varchar to varbinary is not
> allowed
> To: FreeTDS Development Group <[email protected]>
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hari Krishna Dara wrote:
> > I am trying to insert data into a varbinary column from python via
> > pyodbc and unixODBC and get the below error:
> >
> > Traceback (most recent call last):
> > ??File "test_pyodbc.py", line 36, in <module>
> > ?? ?cur.execute(sql, (pyodbc.Binary(data),))
> > pyodbc.DataError: ('22018', '[22018] [FreeTDS][SQL Server]Implicit
> > conversion from data type varchar to varbinary is not allowed. Use the
> > CONVERT function to run this query. (257) (SQLPrepare)')
> >
> > The error occurs no matter what the data contains and how long it is
> > (happens with empty data also).
>
>
> http://manuals.sybase.com:80/onlinebooks/group-cnarc/cng1110e/dblib/@ebt-link;pt=45151?target=%25N%15_12482_START_RESTART_N%25
>
> Designed behavior.  Binary != text.
>
> --jkl
>

Since I am using pyodbc.Buffer (which itself is mapped to python's built-in
buffer type), this is not text. If somewhere in the stack, it is being
treated as text, then it is a bug.

-- Hari
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.