Friday, February 24, 2012

BLOB

Hello,
I am looking into storing images into SQL and want to use BLOB which I
understand to be the best method. Can someone supply me with a simple
example of how to import a file into the database?
Thanks in advance,
John
Well it is amazing what you find after you post. After much searching I
found it on my own. For anyone else who may have wanted to know how to
populate a image type, there is an executable that will do it called
TextCopy.exe. A sample command line is below.
C:\MyDocs\My
Pictures>textcopy -I -Usa -PMyPassword -SMyServer -DMyDatabase -TMyTable -CI
mageColumn -W"where ID = 3" -Fsample.jpg /Z
TEXTCOPY Version 1.0
DB-Library version 8.00.194
debug: Final parameters:
debug: Server: MyServer
debug: Login: sa
debug: Password: MyPassword
debug: Database: MyDatabase
debug: Table: MyTable
debug: Column: ImageColumn
debug: Where clause: where ID = 3
debug: File: sample.jpg
debug: Direction: Into SQL Server from file.
debug: Chunk size: 4096 bytes
SQL Server 'MyServer' Message 5701: Changed database context to 'master'.
SQL Server 'MyServer' Message 5701: Changed database context to
'MyDatabase'. (Concerning line 1)
debug: Query: select ImageColumn from MyTable where ID = 3
debug: File 'sample.jpg' opened for read
debug: File is 9894 bytes long
debug: Read 4096 bytes from file
debug: Read 4096 bytes from file
debug: Read 1702 bytes from file
debug: File closed
Data copied into SQL Server image column from file 'sample.jpg'.
The other key I found is that the existing column must not be null. I
resolved this by running the following.
INSERT INTO [dbo].[MyTable] VALUES ('3', 0x0 )
If you don't do this you will get the following error when you run in debug
(-Z)
ERROR: Text or image pointer and timestamp retrieval failed.
There is also a stored procedure if you would like it let me know and I can
post that as well.
-John
"John A. Curry" <JohnCurry@.Captaris.com> wrote in message
news:uzYznuiXEHA.2408@.tk2msftngp13.phx.gbl...
> Hello,
> I am looking into storing images into SQL and want to use BLOB which I
> understand to be the best method. Can someone supply me with a simple
> example of how to import a file into the database?
> Thanks in advance,
> John
>

No comments:

Post a Comment