Murray Brown
asked on
Excel VB.net Add-in Copy Image straight to Excel from SQL
Hi
In my Excel VB.net add-in I am using the following code to retrieve an image from a SQL database
and copy it to to a picture box on a form. How do I alter the code to copy it direct to Excel?
Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
Dim cn As SqlConnection
cn = New SqlConnection
cn.ConnectionString = My.Settings.CS
Dim cmd As New System.Data.SqlClient.SqlC ommand("Se lect Photo from Information where Name='b'")
cmd.Connection = cn
cmd.CommandType = CommandType.Text
cn.Open()
Dim ImgStream As New IO.MemoryStream(CType(cmd. ExecuteSca lar, Byte()))
PictureBox1.Image = System.Drawing.Image.FromS tream(ImgS tream)
ImgStream.Dispose()
cmd.Connection.Close()
End Sub
In my Excel VB.net add-in I am using the following code to retrieve an image from a SQL database
and copy it to to a picture box on a form. How do I alter the code to copy it direct to Excel?
Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
Dim cn As SqlConnection
cn = New SqlConnection
cn.ConnectionString = My.Settings.CS
Dim cmd As New System.Data.SqlClient.SqlC
cmd.Connection = cn
cmd.CommandType = CommandType.Text
cn.Open()
Dim ImgStream As New IO.MemoryStream(CType(cmd.
PictureBox1.Image = System.Drawing.Image.FromS
ImgStream.Dispose()
cmd.Connection.Close()
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER