2013-02-12 29 views
0

我有vb中的方法圖像條形碼我想將圖像條形碼保存到數據集中? 在frm_Reporting中,我有水晶報表查看器並放入barcodeImage,當btnEncode正在調用時,圖像條形碼已創建,則必須將 插入數據集。如何將圖像添加到vb中的數據集?

Private Sub Frm_Reporting_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
     CrystalReportViewer1.ReportSource = Nothing 
     Dim rptbarcode As RptPacking 
     rptbarcode = New RptPacking 
     Dim xrep As DataSet1 
     xrep = New DataSet1 
     Dim row As DataRow 
     Dim MyImg As Image = Nothing 
     Try 
      btnEncode(MyImg, BarcodeText) 
      row = xrep.Tables(0).NewRow 
      xrep.Tables("DataTable1").Rows(0).SetAdded = MyImg 
      CrystalReportViewer1.ReportSource = rptbarcode 
      rptbarcode.SetDataSource(xrep) 
      rptbarcode.PrintToPrinter(1, False, 0, 0) 
     Catch ex As Exception 
     End Try  
    End Sub 

Private Sub btnEncode(ByRef pic As Image, ByVal txtData As String) 
     Dim W As Integer = 160 
     Dim H As Integer = 110 
     Dim b As BarcodeLib.Barcode 
     Dim type As BarcodeLib.TYPE = BarcodeLib.TYPE.UNSPECIFIED 
     type = BarcodeLib.TYPE.CODE128 
     b = New BarcodeLib.Barcode() 
     Try 
      If type <> BarcodeLib.TYPE.UNSPECIFIED Then 
       b.IncludeLabel = True 

       '===== Encoding performed here ===== 
       pic = b.Encode(type, txtData, W, H) 
       'CType(Frm, frm_submitentery).pic_img.Image = pic.Image 
       '=================================== 


      End If 

     Catch ex As Exception 
      'try 
      MessageBox.Show(ex.Message) 
      'catch 
     End Try 

    End Sub 

回答

0

您可以將圖像中的虛擬目錄,然後使用文件流的轉換對字節數組

相關問題