all groups > sql server programming > december 2004 >
You're in the

sql server programming

group:

Copy image BLOB from one table to another


Copy image BLOB from one table to another SLP
12/17/2004 9:36:57 PM
sql server programming:
I need some urgent help with copying an image field from one SQL Server
table to another.

This is a vb.net web application with a SQL Server 2000 database. I need to
be able to copy a signature, without the need to display the signature on
the web page. Have been trying to do it with a sp without success. I've read
up as much as I can about BLOBs, and understand the principle, but
struggling to know how to work with the data.

I thought that I had found a solution with code in a post by Donald Welker
(http://www.google.com.au/groups?hl=en&lr=&threadm=uLqS5D05DHA.2300%40TK2MSFTNGP10.phx.gbl&rnum=2&prev=/groups%3Fq%3Dcopying%2Bblobs%2Bfrom%2Bone%2Btable%2Bto%2Banother%2Bin%2BSQL%2BServer%26hl%3Den%26lr%3D%26selm%3DuLqS5D05DHA.2300%2540TK2MSFTNGP10.phx.gbl%26),
but this fails on the line:

WRITETEXT holddups.mytext @dst @x -- clear existing if any

with the message

NULL textptr (text, ntext, or image pointer) passed to WriteText function.

In these two MS KB articles http://support.microsoft.com/kb/316887/EN-US/
and http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q317034 I think
I would be able to do it via the web app, but this means creating the image
file between read and write and I want to avoid doing that unless I have to.

As I've been writing here have found in BOL an example using ADO with
SQLOLEDB and VB. I'll try and convert this to ADO.net, but with my lack of
ADO.net experience I can imagine it's going to be a slow, painful process!!

Can someone help? I've been struggling with this for a month, and it's the
only issue left to resolve to complete this web application. The application
has already been delivered to the client but he refuses to pay (big $,
because it's quite a large administrative application) until this is
finished.

Thanks in advance,
Sharon.

Re: Copy image BLOB from one table to another SLP
12/18/2004 12:23:15 AM
Problem solved, with a vb.net procedure, but I'd still like to know how to
do it with a SQL stored procedure. Can anyone give me some ideas?

Using vb.net, I combined the two read- and write-blob procedures in the MS
KB into one, bypassing creating the file, and it is working ok with:

Create a select command
Create and open a connection
Create data reader and read
Declare a byte variable b and fill it with the data from the data reader
Create an update command
Declare a SQL image datatype parameter
Add the parameter to the update command
Execute the update command
Close the connection


[quoted text, click to view]

Re: Copy image BLOB from one table to another Steve Kass
12/18/2004 9:08:07 AM
Did you try an update query?

update destinationTable set
signatureColumn = sourceTable.signatureColumn
from sourceTable
where sourceTable.RowID = @fromRow
and destinationTable.RowID = @toRow

Steve Kass
Drew University

[quoted text, click to view]
AddThis Social Bookmark Button