Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Store Images

Author  Topic 

ramgopal
Starting Member

4 Posts

Posted - 2003-06-04 : 08:38:04
hai,
Thanks for the replies.
i want to store an image(ex: Scanned Passport size photo) to be stored along with the employee. There is a datatype IMAGE in Sql Server. How do u store images into that field. using VB and ADO. The image will be in imagebox or picture box. How will i do it.

if i can have sample code i appereciate it.

thank u.

by gopal


Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2003-06-04 : 08:52:42
NO
NO
NO
NO
NO

I do not recommend it

If you are determined to do it, there some links in the FAQ




Damian
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-06-04 : 13:08:29
quote:

NO
NO
NO
NO
NO

I do not recommend it

If you are determined to do it, there some links in the FAQ




Damian



NO
No
nO
Non
Nein
Não
Nr - (dutch...not the world famous Nigel)
Αριθ
Нет

how many way to say No...

Store pointer to image files and save your hair.



Brett

8-)
Go to Top of Page

ramgopal
Starting Member

4 Posts

Posted - 2003-06-10 : 01:49:43
hai,

thanks for replies.
after reading replies i came to conclusion that it is bad to store images. presently i am following the techniques u specified (storing the paths to images).

but recently i attended two interviews. In both they asked the same questions. I replied that it is bad to store images and told that i will store paths to images (i Think they were not satified with the answer and that lead to amny other questions.

so i expect some other guy will ask the same question and i would like give straight answers avoid further questions on this topic(its better).

therefore can any tell me with syntax how to do this. The Links did not provide much information.

also can u tell any book titles that teach SQL Server from beginning to faily complex level ( Creating procedures in SQL Server, About System procedures etc).

Thank U
gopal



Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-06-10 : 16:43:35
Here, knock yourself out...

Understand that you'll need an iterative process to get all the blocks of data:



CREATE PROCEDURE ImageTest3

-- @ptrValue varbinary(16)
@Offset int
, @Size int
AS

-- Execute ImageTest3
--
-- Enterprise Solutions
--
-- File: ImageTest3.sql
-- Date: March 4th, 2002
-- Author: Brett Kaiser
-- Server:
-- Database: ImageTest3
-- Description: Investigate how to extract blobs fro SQL Server 7
--
-- The stream will do the following:
--
-- 1.
--
--
--
--
-- Tables Used:
-- Table1
--
--
-- Tables Created: None
--
--
-- Row Estimates:
-- name rows reserved data index_size unused
-- -------------------- ----------- ------------------ ------------------ ------------------ ------------------
--
--Change Log
--
-- UserId Date Description
-- ----------- -------------- ------------------------------------------------------------------------------------------
-- x002548 12/14/2001 1. Initial release
--
--
--

Declare @error_out int, @Result_Count int, @Error_Message varchar(255), @Error_Type int, @Error_Loc int

Declare @ptrValue varbinary(16)

Begin

Begin Tran
Select @ptrValue = TextPtr(imgPicture) from Table1 Where charKey = 'A'

If TextValid('Table1.imgPicture', @ptrValue) <> 1
BEGIN
Select @Error_Loc = 1
Select @Error_Message = 'Pointer value not valid. Value equals: ' + RTrim(Convert(Char(16),@ptrValue))
Select @Error_Type = 50002
GOTO ImageTest3_Error
END

ReadText Table1.imgPicture @ptrValue @Offset @Size

Select @Result_Count = @@ROWCOUNT, @error_out = @@error

If @error_out <> 0
BEGIN
Select @Error_Loc = 2
Select @Error_Type = 50001
GOTO ImageTest3_Error
END

If @Result_Count = 0
BEGIN
Select @Error_Loc = 2
Select @Error_Message = 'Could Not find image for pointer value ' + RTrim(Convert(Char(16),@ptrValue))
Select @Error_Type = 50002
GOTO ImageTest3_Error
END

If @Result_Count > 1
BEGIN
Select @Error_Loc = 2
Select @Error_Message = 'Found multiple images for pointer value ' + RTrim(Convert(Char(16),@ptrValue))
Select @Error_Type = 50002
GOTO ImageTest3_Error
END

End

ImageTest3_Exit:

COMMIT TRAN
Return

ImageTest3_Error:

Rollback TRAN

If @Error_Type = 50001
BEGIN
Select @error_message = (Select 'Location: ' + RTrim(Convert(char(3),@Error_Loc))
+ ' @@ERROR: ' + RTrim(Convert(char(6),error))
+ ' Severity: ' + RTrim(Convert(char(3),severity))
+ ' Message: ' + RTrim(description)
From master..sysmessages
Where error = @error_out)
END
If @Error_Type = 50002
BEGIN
Select @Error_Message = 'Location: ' + RTrim(Convert(char(3),@Error_Loc))
+ ' Severity: UserLevel '
+ ' Message: ' + RTrim(@Error_Message)
END

RAISERROR @Error_Type @Error_Message
Return

GO


Brett

8-)
Go to Top of Page

ramgopal
Starting Member

4 Posts

Posted - 2003-06-11 : 02:51:56
thanks X002548
i really appreciate it.

i didnt think that this would be this difficult and complex.

thanks again

Go to Top of Page
   

- Advertisement -