Solved

Save images to SQL server (BLOB) ?

Posted on 2006-11-01
5
422 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

751 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