title: Dynamically adding multiple Images to a Crystal Report in vb.net (WinForms)
body: <p>Looking for some assistance.</p>
  
  <p>I have previously added a single image to a Crystal Report using a DataSet and a subform.</p>
  
  <p>I thought that I would be able to replicate this for multiple images.</p>
  
  <p>I have created the Dataset 'Images' with 8 rows named img1 -> img8</p>
  
  <p>I have created a Subreport based on that dataset.</p>
  
  <p>In my vb code I set the datasource of the SubReport as follows:</p>
  
  <p>Initial Call:</p>
  
  <pre><code>    alertReport.OpenSubreport("AlertImages").SetDataSource(CreateImages(alertID))
  </code></pre>
  
  <p>Create Images:</p>
  
  <pre><code>Private Function CreateImages(ByVal alertID As Integer) As DataSet
  
          Dim data As New DataSet()
  
          data.Locale = Globalization.CultureInfo.InvariantCulture
          data.Tables.Add("Images")
          data.Tables(0).Columns.Add("img", System.Type.GetType("System.Byte[]"))
  
          Try
  
              Dim path As String = String.Format("{0}\{1}", HighAlertPath, alertID.ToString())
  
              If (Directory.Exists(path)) Then
  
                  Dim cnt As Integer = 1
  
                  For Each fi As FileInfo In New DirectoryInfo(path).GetFiles
  
                      If (cnt &lt;= 8) Then
  
                          If (fi.Extension = ".jpg" Or fi.Extension = ".png" Or fi.Extension = ".bmp") Then
  
                              Dim row As DataRow = GetImageRow(data.Tables(0), fi.FullName)
                              data.Tables(0).Rows.Add(row)
                              cnt += 1
  
                          End If
  
                      End If
                  Next
  
              End If
  
          Catch ex As Exception
          End Try
  
          Return data
  
      End Function
  </code></pre>
  
  <p>Get Image Row:</p>
  
  <pre><code>Private Function GetImageRow(ByVal tbl As DataTable, ByVal fileName As String) As DataRow
  
      Using fs As New FileStream(fileName, FileMode.Open)
          Using br As New BinaryReader(fs)
  
              Dim row As DataRow = tbl.NewRow()
              row(0) = br.ReadBytes(CInt(br.BaseStream.Length))
  
              Return row
  
          End Using
      End Using
  
  End Function
  </code></pre>
  
  <p>I can confirm that the file location does have images in, and they are added to the datatable, but for some reason they do not show in the sub report.</p>
  
  <p>do I need to name the rows as they are added to the datatable, since my subreport expects fields img1 -> img8</p>