By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,515 Members | 1,061 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,515 IT Pros & Developers. It's quick & easy.

Dynamically add Image on crystal report vb.net

P: 4
I am working on project . I have to Retrieve image from Database Table (table 1) . Image is stored in Image data-type in table 1 . Then i have to put this image on crystal report. I have searched a lot for this topic but not successfully completed this task.

Actually i want to retrieve the employee details along with their images from database and get all on crystal report

I am using :-
vs 2010
SAP crystal reports 13
using vb or c#

Here is code that i am using :
Expand|Select|Wrap|Line Numbers
  1. Dim con As New SqlConnection("Data Source=HB-6F0B5AC76D8E;Initial Catalog=putimage;Integrated Security=True")
  2.         con.Open()
  3.         Dim cmd As New SqlCommand("select * from table1", con)
  4.         Dim da As New SqlDataAdapter
  5.         da.SelectCommand = cmd
  6.         Dim ds As New DataSet
  7.         da.Fill(ds)
  8.         Dim a As Byte() = ds.Tables(0).Rows(0).Item(0)
  9.         Dim b = ds.Tables(0).Rows(0).Item(0)
  10.         Dim ms As New System.IO.MemoryStream(a)
  11.         Dim img As System.Drawing.Image = System.Drawing.Image.FromStream(ms)
  12.         Dim dt As New DataTable
  13.         dt.Columns.Add("pic")
  14.         dt.Rows.Add(b)
  15.  
  16.         'rpt.Load("S:\vb & vb.net\project done\WindowsApplication3\WindowsApplication3\CrystalReport1.rpt")
  17.         'rpt.SetDataSource(dt)
  18.         'Form2.CrystalReportViewer1.ReportSource = rpt
  19.         '  Form2.Show()
  20.  
  21.         PictureBox1.Image = img
  22.         MsgBox("DONE")
  23.  
  24.         cmd.Dispose()
  25.         con.Dispose()
  26.  
Dec 7 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.