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
 HEX picture information to SQL2005

Author  Topic 

meenu.monu
Starting Member

8 Posts

Posted - 2010-07-15 : 10:19:52
dears the following line is some picture information in HEX .I wanted to store this hex information in SQL image(data type) field.How can i do this.PLS pls help me.

0001FFD8FFE000104A46494600010100000100010000FFDB0043000C08080A08080C0A0A0A0C0C0C0E101C121010101022181A141C28222A28262226262C303E342C2E3A2E2626364A363A40424646462A344C524C44503E444642FFDB0043010C0C0C100E1020121220422C262C4242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242FFC4001F000001050101010101010000000000000000010203

pls give me some code sample

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-07-15 : 10:30:05
[code]DECLARE @Sample TABLE (BinaryData VARBINARY(MAX))

INSERT @Sample (BinaryData)
SELECT 0x0001FFD8FFE000104A46494600010100000100...[/code]


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

meenu.monu
Starting Member

8 Posts

Posted - 2010-07-18 : 04:48:00
dear friend,Thanks for ur response.

following is the picture data in Hex fomrat.

0001FFD8FFE000104A46494600010100000100010000FFDB0043000C08080A08080C0A0A0A0C0C0C0E101C121010101022181A141C28222A28262226262C303E342C2E3A2E2626364A363A40424646462A344C524C44503E444642FFDB0043010C0C0C100E1020121220422C262C4242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242FFC4001F000001050101010101010000000000000000010203

In sql i inserted this data in an image coloumn like as follows(added ox).

INSERT INTO [Test_mm].[dbo].[PictureTable]
([Title]
,[DateAdded]
,[MIMEType]
,[Image])
VALUES
('jjj'
,'6/22/2010 3:12:04 PM'
,'hjhg'
,'0x0001FFD8FFE000104A46494600010100000100010000FFDB0043000C08080A08080C0A0A0A0C0C0C0E101C121010101022181A141C28222A28262226262C303E342C2E3A2E2626364A363A40424646462A344C524C44503E444642FFDB0043010C0C0C100E1020121220422C262C4242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242FFC4001F000001050101010101010000000000000000010203')

after inserting the data i tried to display this using the code below.But it is giving me an error?


Dim ImageID As Integer = Convert.ToInt32(Request.QueryString("ImageID"))
Using myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("NorthwindConnection").ConnectionString)
Const SQL As String = "SELECT [MIMEType], [Image] FROM [PictureTable] WHERE [ImageID] = @ImageID"

Dim myCommand As New SqlCommand(SQL, myConnection)
myCommand.Parameters.AddWithValue("@ImageID", ImageID)

myConnection.Open()
Dim myReader As SqlDataReader = myCommand.ExecuteReader

If myReader.Read Then
Response.ContentType = myReader("MIMEType").ToString()
Response.BinaryWrite(myReader("Image"))
End If

myReader.Close()
myConnection.Close()
End Using

can u help me to solve this ?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-07-18 : 14:35:49
I can't recollect I used single quotes?

INSERT INTO [Test_mm].[dbo].[PictureTable]
(
[Title]
,[DateAdded]
,[MIMEType]
,[Image]
)
VALUES
(
'jjj'
,'6/22/2010 3:12:04 PM'
,'hjhg'
,0x0001FFD8FFE000104A46494600010100000100010000FFDB0043000C08080A08080C0A0A0A0C0C0C0E101C121010101022181A141C28222A28262226262C303E342C2E3A2E2626364A363A40424646462A344C524C44503E444642FFDB0043010C0C0C100E1020121220422C262C4242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242FFC4001F000001050101010101010000000000000000010203
)


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

meenu.monu
Starting Member

8 Posts

Posted - 2010-07-19 : 02:07:01

dear friend ,
insert query is working fine...i did that...my requirement is to i need to diplay this picture in asp.net
Go to Top of Page
   

- Advertisement -