Solved

Save images to SQL server (BLOB) ?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

914 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

16 Experts available now in Live!

Get 1:1 Help Now