Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Save images to SQL server (BLOB) ?

Posted on 2006-11-01
5
Medium Priority
?
424 Views
Last Modified: 2008-01-09
Problem:

Use Webcam to capture snapshot of clients but has to work through terminal services (which does not connect your local webcam to your TS session).

Probable solutions:

Use standalone pc to save images to FTP site, terminal server app gets it from their.
(Any ideas on this?)

Use standalone pc to save images directly to the SQL database (BLOB) and terminal server app gets it from their.
(How do I save images to SQL and retreive them?)

Pick one , preferably option 2.

Thanks
0
Comment
Question by:x50Fade
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 2

Author Comment

by:x50Fade
ID: 17849598
their being there
0
 
LVL 6

Accepted Solution

by:
Jayadev Nair earned 620 total points
ID: 17849941
Hi

You have an Image object or image in a file?

Private Sub Execute()
'> Read Image into Byte array
 Dim photo() as Byte = GetPhoto(photoFilePath)
 Dim connection As SqlConnection = New SqlConnection(connectionString)
 Dim command As SqlCommand = New SqlCommand("INSERT INTO Table (Photo) Values(@Photo)", connection)
'> Assign Byte Array
 command.Parameters.Add(@Photo,SqlDbType.Image, photo.Length).Value = photo
 connection.open()
'> Execute
 command.executeNonQuery()
 connection.dispose()
End Sub

Private Shared Function GetPhoto(filePath As String) As Byte()
  Dim stream As FileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read)
  Dim reader As BinaryReader = new BinaryReader(stream)
  Dim photo() As Byte = reader.ReadBytes(stream.Length)
  reader.Close()
  stream.Close()
  Return photo
End Function


If you have Image in a System.Drawing.Image object, use MemoryStream instead of Binary File Reader and turn it to Byte Array

Thanks.
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question