Solved

Save images to SQL server (BLOB) ?

Posted on 2006-11-01
5
416 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
5 Comments
 
LVL 2

Author Comment

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

Accepted Solution

by:
Jayadev Nair earned 155 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now