Solved

Save images to SQL server (BLOB) ?

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Put window Form inside tab page 10 33
Write to a printer using vb.net 9 31
Sql server, import complete table, using vb.net 9 36
location of a form 2 15
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

832 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